Page 1 of 1

Bug? Multi connection didn't roll over

Posted: Tue May 13, 2008 9:57 pm
by Flurrywinde
This is v.3.3.2 in php4.

My connection is a multi:

Code: Select all

$connections_gmail = array();
$connections_def = array();
 
$conn_g0 =& new Swift_Connection_SMTP("smtpauth.fairpoint.net");
$conn_g0->setUsername("kanon11@fairpoint.net");
$conn_g0->setPassword("hotmouse");
$connections_gmail[] =& $conn_g0;
 
$conn_g =& new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS);
$conn_g->setUsername("playbyweb@gmail.com");
$conn_g->setPassword("worgus11");
$connections_gmail[] =& $conn_g;
 
$conn_g2 =& new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS);
$conn_g2->setUsername("pbw.emailer@gmail.com");
$conn_g2->setPassword("worgus11");
$connections_gmail[] =& $conn_g2;
 
// Add another Gmail connection here if needed. Will also have to edit function gmail_conn() if you do so. 
 
$conn_s =& new Swift_Connection_Sendmail();
$connections_gmail[] =& $conn_s;
$connections_def[] =& $conn_s;
 
$conn_n =& new Swift_Connection_NativeMail();
$connections_gmail[] =& $conn_n;
$connections_def[] =& $conn_n;
 
$mailer_gmail =& new Swift(new Swift_Connection_Multi($connections_gmail));
$mailer_def =& new Swift(new Swift_Connection_Multi($connections_def));
 
//1 mails per batch with a 10 second pause between batches (Author suggests 100/batch, 30 sec.
$mailer_gmail->attachPlugin(new Swift_Plugin_AntiFlood(1, 10), "anti-flood");
$mailer_def->attachPlugin(new Swift_Plugin_AntiFlood(1, 10), "anti-flood");
 
// Report any errors that occurred.
if ($e !== null) { echo "An error occurred" . $e->getMessage(); }
else Swift_Errors::clear("Swift_Exception");
 
Here's the full log my code produces if you need it, but the main idea is that the connection to Gmail SMTP fails, but later, it does not roll over to the next connection like Swift_Connection_Multi is supposed to.

Code: Select all

An error occurredAuthentication failed using username 'playbyweb@gmail.com' and password '********'Free For All (3e) - Secret Stuff - 1 new messages sent to (12:36:24):
 
    Flax - im2l8m8@hotmail.com
 
Free For All (3e) - Find the herrings - 2 new messages sent to (12:36:34):
 
    Flax - im2l8m8@hotmail.com
    flurrywind - kanon11@yahoo.com (Send by Gmail SMTP)
    Torenai - cheatman@msn.com
    jatarri - jatarri1@gmail.com
    E-mails sent by Gmail SMTP: 1 (This time: 1) Used connection: Gmail #0 (playbyweb@gmail.com)
An error occurredExpected response code(s) [250] but got response [530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://mail.google.com/support/bin/answ ... swer=14257 y67sm698870pyg.39]<h3>Log Information</h3><pre><< 250-zibal.lunarservers.com Hello playb4 at [74.50.5.131]
250-SIZE 52428800
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
++ Message sent to 1/1 recipients
>> MAIL FROM: <emailer@playbyweb.com>
<< 250 OK
>> RCPT TO: <im2l8m8@hotmail.com>
<< 250 Accepted
>> DATA
<< 354 Enter message, ending with "." on a line by itself
>> <MESSAGE DATA>
>> 
.
<< 250 OK id=1Jw0Ic-0004np-NO
>> QUIT
<< 221 zibal.lunarservers.com closing connection
<< 220-zibal.lunarservers.com ESMTP Exim 4.68 #1 Tue, 13 May 2008 12:36:44 -0700
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
>> EHLO [74.50.5.131]
<< 250-zibal.lunarservers.com Hello playb4 at [74.50.5.131]
250-SIZE 52428800
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
++ Message sent to 1/1 recipients
>> MAIL FROM: <emailer@playbyweb.com>
<< 250 OK
>> RCPT TO: <cheatman@msn.com>
<< 250 Accepted
>> DATA
<< 354 Enter message, ending with "." on a line by itself
>> <MESSAGE DATA>
>> 
.
<< 250 OK id=1Jw0In-0004tF-40
>> QUIT
<< 221 zibal.lunarservers.com closing connection
<< 220-zibal.lunarservers.com ESMTP Exim 4.68 #1 Tue, 13 May 2008 12:36:57 -0700
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
>> EHLO [74.50.5.131]
<< 250-zibal.lunarservers.com Hello playb4 at [74.50.5.131]
250-SIZE 52428800
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
++ Message sent to 1/1 recipients
>> MAIL FROM: <emailer@playbyweb.com>
<< 250 OK
>> RCPT TO: <jatarri1@gmail.com>
<< 250 Accepted
>> DATA
<< 354 Enter message, ending with "." on a line by itself
>> <MESSAGE DATA>
>> 
.
<< 250 OK id=1Jw0J0-0004xv-2l
>> QUIT
<< 221 zibal.lunarservers.com closing connection
<< 220-zibal.lunarservers.com ESMTP Exim 4.68 #1 Tue, 13 May 2008 12:37:08 -0700
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
>> EHLO [74.50.5.131]
<< 250-zibal.lunarservers.com Hello playb4 at [74.50.5.131]
250-SIZE 52428800
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
++ Message sent to 1/1 recipients
>> MAIL FROM: <emailer@playbyweb.com>
<< 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://mail.google.com/support/bin/answ ... swer=14257 y67sm698870pyg.39
!! Expected response code(s) [250] but got response [530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://mail.google.com/support/bin/answ ... swer=14257 y67sm698870pyg.39]</pre>
Free For All (3e) - More Secret Stuff  - 8 new messages sent to (12:37:35):
 
    Flax - im2l8m8@hotmail.com
 
*******************************************
   SENDING NOTES
*******************************************
 
No notes to e-mail on Tuesday 13th of May 2008 12:37:45 PM
 
*******************************************
   REPORTS
*******************************************
 
Failed recipients: kanon11@yahoo.com
 
SWIFTMAILER LOG:
 
<< 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://mail.google.com/support/bin/answ ... swer=14257 y67sm698870pyg.39
!! Expected response code(s) [250] but got response [530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://mail.google.com/support/bin/answ ... swer=14257 y67sm698870pyg.39]
>> RCPT TO: <kanon11@yahoo.com>
<< 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://mail.google.com/support/bin/answ ... swer=14257 y67sm698870pyg.39
!! Expected response code(s) [250] but got response [530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://mail.google.com/support/bin/answ ... swer=14257 y67sm698870pyg.39]
!! Recipient 'kanon11@yahoo.com' rejected by connection.
>> RSET
<< 250 2.1.0 Flushed y67sm698870pyg.39
>> QUIT
<< 221 2.0.0 mx.google.com closing connection y67sm698870pyg.39
<< 220 mx.google.com ESMTP z38sm252179pyg.25
>> EHLO [74.50.5.131]
<< 250-mx.google.com at your service, [74.50.5.131]
250-SIZE 28311552
250-8BITMIME
250-AUTH LOGIN PLAIN
250 ENHANCEDSTATUSCODES
>> AUTH PLAIN cGxheWJ5d2ViQGdtYWlsLmNvbQBwbGF5Ynl3ZWJAZ21haWwuY29tAHdvcmd1czEx
<< 535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://mail.google.com/support/bin/answ ... swer=14257 z38sm252179pyg.25
!! Expected response code(s) [235] but got response [535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://mail.google.com/support/bin/answ ... swer=14257 z38sm252179pyg.25]
>> RSET
<< 250 2.1.0 Flushed z38sm252179pyg.25
>> AUTH LOGIN
<< 334 VXNlcm5hbWU6
>> cGxheWJ5d2ViQGdtYWlsLmNvbQ==
<< 334 UGFzc3dvcmQ6
>> d29yZ3VzMTE=
<< 535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://mail.google.com/support/bin/answ ... swer=14257 z38sm252179pyg.25
!! Expected response code(s) [235] but got response [535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://mail.google.com/support/bin/answ ... swer=14257 z38sm252179pyg.25]
>> RSET
<< 250 2.1.0 Flushed z38sm252179pyg.25
>> QUIT
<< 220 mx.google.com ESMTP s59sm243565pyh.40
<< 220 mx.google.com ESMTP w38sm722201pyg.3
>> EHLO [74.50.5.131]
<< 250-mx.google.com at your service, [74.50.5.131]
250-SIZE 28311552
250-8BITMIME
250-AUTH LOGIN PLAIN
250 ENHANCEDSTATUSCODES
>> AUTH PLAIN cGxheWJ5d2ViQGdtYWlsLmNvbQBwbGF5Ynl3ZWJAZ21haWwuY29tAHdvcmd1czEx
<< 535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://mail.google.com/support/bin/answ ... swer=14257 w38sm722201pyg.3
!! Expected response code(s) [235] but got response [535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://mail.google.com/support/bin/answ ... swer=14257 w38sm722201pyg.3]
>> RSET
<< 250 2.1.0 Flushed w38sm722201pyg.3
>> AUTH LOGIN
<< 334 VXNlcm5hbWU6
>> cGxheWJ5d2ViQGdtYWlsLmNvbQ==
<< 334 UGFzc3dvcmQ6
>> d29yZ3VzMTE=
<< 535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://mail.google.com/support/bin/answ ... swer=14257 w38sm722201pyg.3
!! Expected response code(s) [235] but got response [535-5.7.1 Username and Password not accepted. Learn more at
535 5.7.1 http://mail.google.com/support/bin/answ ... swer=14257 w38sm722201pyg.3]
>> RSET
<< 250 2.1.0 Flushed w38sm722201pyg.3
>> <MESSAGE DATA>
++ Message sent to 1/1 recipients
>> <MESSAGE DATA>
++ Message sent to 1/1 recipients
 

Re: Bug? Multi connection didn't roll over

Posted: Tue May 13, 2008 10:03 pm
by Chris Corbyn
It will only roll over upon making an initial connection. Once it finds a connection that works it sticks with it. The logic has changed in the upcoming version however so it will do as you expect.

2 weeks to beta, tops.

Re: Bug? Multi connection didn't roll over

Posted: Wed May 14, 2008 12:15 am
by Flurrywinde
But it didn't successfully make an initial connection. The error at the top of the log is it failing to authenticate.

(Incidentally, the reason it didn't authenticate is because Gmail seems to have just begun locking the account and requiring a Captcha to unlock if I use the SMTP server too much.)

Can I trap the error (either failing to auth error or the send failing) and make it roll over myself by advancing the $swift->connection->active property?

How stable will the beta be? I might be willing to use it on my production website if it's not too bad, since the e-mails I send are not fantastically critical, just minorly important. ;)

Re: Bug? Multi connection didn't roll over

Posted: Wed May 14, 2008 3:49 am
by Chris Corbyn
Ah, it probably doesn't take into account authentication errors since the original intention of the class was for occassions when a server is offline. Again, in version 4 it will still roll over because it will treat the exception as a bad response.

The beta is unit tested, acceptance tested and smoke tested from all angles. It's stable now from that perspective -- I've been writing it for nearly a year and it's had my attention nearly every day. Like with every programmer who looks back a year later, I've learned a lot since my writing version 3 and I'm in love with the new code base. I'd like to run it marked as beta for a while though for obvious reasons. The library is a huge and doing an entire rewrite of it is a big (and risky) undertaking because every singe little feature which is in the current version has to be in the new version.

I could release it now, but the FileEmbedder plugin is missing and it needs some optimization work -- something I always do last.

Re: Bug? Multi connection didn't roll over

Posted: Wed May 14, 2008 11:25 am
by Flurrywinde
Cool, so what I'll do is install it on my two test servers first and if there are no problems there, begin to use it on my production server.

In the meantime, with v.3, can I trap the errors that aren't automatically being handled correctly by your code (i.e. SMTP failing to authenticate and send() failing in the middle) and make it roll over myself by advancing the $swift->connection->active property?