Page 1 of 1

[SOLVED] 530 5.7.0 Authentication required

Posted: Wed Jan 21, 2009 8:43 am
by kendall
Hi,

I'm using Swift 3.3.1 to send batched mail and I am using the SMTP class to use a sam domain email address to send the mail off. Now the problem i am getting seems to come only when first trying to authenticating as while the first email in the batch fails due to the subject code response the rest is sucessfull....

the log reveals
! Expected response code(s) [250] but got response [530 5.7.0 Authentication required] >> RCPT TO: << 503 5.0.0 Need MAIL before RCPT !! Expected response code(s) [250] but got response [503 5.0.0 Need MAIL before RCPT] !! Recipient 'info@xxxxxxxxx.com' rejected by connection. >> RSET << 250 2.0.0 Reset state >> MAIL FROM: << 530 5.7.0 Authentication required !! Expected response code(s) [250] but got response [530 5.7.0 Authentication required] >> ++ Message sent to 1/1 recipients ++ Closing down SMTP connection. ++ Trying to connect to SMTP server at 'ssl://xxxxxxx.com:465 >> QUIT << 220 xxxxxxxx.com ESMTP Sendmail 8.14.1/8.14.1; Wed, 21 Jan 2009 06:35:51 -0800 (PST) ++ Closing down SMTP connection. ++ Trying to connect to SMTP server at 'ssl://xxxxxx.com:465 << 220 xxxxxx.com ESMTP Sendmail 8.14.1/8.14.1; Wed, 21 Jan 2009 06:35:51 -0800 (PST) >> EHLO [216.55.171.37] << 250-xxxxxx.com Hello xxxxxx.com [xxxxxxxxx], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-8BITMIME 250-SIZE 33554432 250-DSN 250-AUTH CRAM-MD5 LOGIN PLAIN 250-DELIVERBY 250 HELP ++ SMTP extension 'ENHANCEDSTATUSCODES' reported with attributes []. ++ SMTP extension 'PIPELINING' reported with attributes []. ++ SMTP extension '8BITMIME' reported with attributes []. ++ SMTP extension 'SIZE' reported with attributes [33554432]. ++ SMTP extension 'DSN' reported with attributes []. ++ SMTP extension 'AUTH' reported with attributes [CRAM-MD5, LOGIN, PLAIN]. ++ SMTP extension 'DELIVERBY' reported with attributes []. ++ SMTP extension 'HELP' reported with attributes []. ++ Trying to authenticate with username 'no-replies@xxxxxxxxxxx.com'. ++ No authenticators loaded; looking for defaults. ++ Authentication mechanism 'CRAM-MD5' attached. ++ Authentication mechanism 'LOGIN' attached. ++ Authentication mechanism 'PLAIN' attached. ++ Trying 'CRAM-MD5' authentication... >> AUTH CRAM-MD5 << 334 PDMxNTU1MjkxODcuNzgxMTg1N0Bwcm8zMi5hYmFjLmNvbT4= >> bm8tcmVwbGllc0BidXNpbmVzc2luc2lnaHRjYXJpYmJlYW4uY29tIGUxYzYxMGJiMGUxMzllOTJjMTY0ODc0MGJmMDcxNTBi << 235 2.0.0 OK Authenticated ++ Success! Authentication accepted. >> MAIL FROM: << 250 2.1.0 ... Sender ok >> RCPT TO: << 250 2.1.5 ... Recipient ok >> DATA << 354 Enter mail, end with "." on a line by itself >> >> . << 250 2.0.0 n0LEZpqv029528 Message accepted for delivery ++ Message sent to 1/1 recipients

the code i start off with is

Code: Select all

 
$swift =& new Swift($conn =& new Swift_Connection_SMTP($smtp_server, 465, 4));
$conn->setUsername($smtp_email);
$conn->setPassword($smtp_pass); 
 
what gives? as If i substituted the email for an email that was successful still....the first email will not be sent as it is rejected.

Re: 530 5.7.0 Authentication required

Posted: Wed Jan 21, 2009 7:08 pm
by Chris Corbyn
You can't do what you're trying to do. The constructor of Swift Mailer attempts to connect and authenticate (using the connection). If you pass the username and password after you've started Swift Mailer then it's too late:

Code: Select all

$conn =& new Swift_Connection_SMTP($smtp_server, 465, 4)
$conn->setUsername($smtp_email);
$conn->setPassword($smtp_pass); 
$swift =& new Swift($conn);
NOTE: Your previous approach does work in the new version (beta) since it connects as late as possible, compared to the current approach of connecting as early as possible.