Difference between errors on sending massive email

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
daneel
Forum Newbie
Posts: 19
Joined: Wed Apr 09, 2008 3:39 pm

Difference between errors on sending massive email

Post by daneel »

Hi, I have another quiestion... is there a way to difference between "error kinds" when sending massive email ? I mean, there could be at least two kind of error: smtp connection error (not being able to send for X reason ANY email) and an address error (what means that swift can't send to that particular recipient, but can keep sending).
The reason for this is that, as far as I see, using BatchMailer I can only get the failed addresses, but I can't know why it happened. And it would be great for me to distinguish if it's an address error (that I can track and warn the system's user) or if is there an SMTP error (to advice the user and tell him to call to the hosting company).

Well, that's all... :roll:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Difference between errors on sending massive email

Post by Chris Corbyn »

PHP 4 or 5?

Swift_BadResponseException is for errors such as not being able to relay to an address.
Swift_ConnectionException is for all other connection errors.

Swift_BadResponseException is a subclass of ConnectionException and therefore if you want to catch both:

Code: Select all

try {
  //code here
} catch (Swift_BadResponseException $e) {
  //Bad response from SMTP server
} catch (Swift_ConnectionException $e) {
  //SMTP connection error
}
daneel
Forum Newbie
Posts: 19
Joined: Wed Apr 09, 2008 3:39 pm

Re: Difference between errors on sending massive email

Post by daneel »

Thanks ! It's AMAZING how fast you answer ! :drunk:

Well, in fact after I wrote the post I realize that I was missunderstanding the BachtMailer process... I think :oops:

Tell me if I'm wrong: the process returns the count of mails sended and an array with failed addresses, and if it reaches X exceptions (not failed addresses!) it throws an exception... so, if there was an SMTP error it throws an exception, but if the address is not accepted it just adds it to "failedRecipients" and goes on... right ?

I thought that failed recipients and throwing the exception were both "the same", that's why I asked how to distinghis between error types.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Difference between errors on sending massive email

Post by Chris Corbyn »

Failed recipients and throwing an exception are the same for send(), but with batchSend() the exception is a signal for swift to retry. The retry is a per-address feature so up to 2 exceptions may occur per recipient with batchSend().

Sorry, tad drunk, it's my birthday and just got home from a night out :)
daneel
Forum Newbie
Posts: 19
Joined: Wed Apr 09, 2008 3:39 pm

Re: Difference between errors on sending massive email

Post by daneel »

First, happy birthday ! :rofl:

Now, I'm using BachtMailer, no sendBacht method from Swift (just in case it makes any difference)

So, I think I don't understand :cry:

With BachtMailer, if an address is bad written... what happens?
In other words, why could it be that an address fails but another one doesn't, and could it be that doesn't matter what the address is, the server it's just not wonrking... is there a way to difference this ?

I thought that in BachtMailer, if it throws an exception it means is somehting wrong with the server, and failed recipients means that is somehting wrong with their addresses. It happened to me ... the process throwed an exception, but no failed recipients were registered.

I think maybe I missing some SMTP knowledge here
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Difference between errors on sending massive email

Post by Chris Corbyn »

BatchMailer behaves in exactly the same way as mentioned above :)

If an address fails it's probably not because the server isn't working, but rather because the server is configured to reject it.

If all you're looking for is debug logic take a look at the logging stuff in the wiki ;)
daneel
Forum Newbie
Posts: 19
Joined: Wed Apr 09, 2008 3:39 pm

Re: Difference between errors on sending massive email

Post by daneel »

I get this log:
>> EHLO bbg-mail.net
<< 250-smtp177.allytech.com Hello smtp177.allytech.com [200.49.145.177], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE 30000000
250-DSN
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 [30000000].
++ SMTP extension 'DSN' reported with attributes [].
++ SMTP extension 'DELIVERBY' reported with attributes [].
++ SMTP extension 'HELP' reported with attributes [].
>> MAIL FROM: <envio@bbg-mail.net>
<< 250 2.1.0 <envio@bbg-mail.net>... Sender ok
>> RCPT TO: <silvio.storani@bsg.com.ar>
++ Closing down SMTP connection.
++ Trying to connect to SMTP server at 'bbg-mail.net:25
>> QUIT
<< 220 ServerMail.ns20 ESMTP
++ Closing down SMTP connection.
++ Trying to connect to SMTP server at 'bbg-mail.net:25
<< 220 ServerMail.ns20 ESMTP
>> EHLO bbg-mail.net
<< 250-smtp177.allytech.com Hello smtp177.allytech.com [200.49.145.177], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE 30000000
250-DSN
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 [30000000].
++ SMTP extension 'DSN' reported with attributes [].
++ SMTP extension 'DELIVERBY' reported with attributes [].
++ SMTP extension 'HELP' reported with attributes [].
>> MAIL FROM: <envio@bbg-mail.net>
<< 250 2.1.0 <envio@bbg-mail.net>... Sender ok
>> RCPT TO: <silvio.storani@bsg.com.ar>
++ Closing down SMTP connection.
++ Trying to connect to SMTP server at 'bbg-mail.net:25
>> QUIT
<< 220 ServerMail.ns20 ESMTP
++ Closing down SMTP connection.
++ Trying to connect to SMTP server at 'bbg-mail.net:25
<< 220 ServerMail.ns20 ESMTP
>> EHLO bbg-mail.net
<< 250-smtp177.allytech.com Hello smtp177.allytech.com [200.49.145.177], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE 30000000
250-DSN
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 [30000000].
++ SMTP extension 'DSN' reported with attributes [].
++ SMTP extension 'DELIVERBY' reported with attributes [].
++ SMTP extension 'HELP' reported with attributes [].
>> MAIL FROM: <envio@bbg-mail.net>
<< 250 2.1.0 <envio@bbg-mail.net>... Sender ok
>> RCPT TO: <silvio.storani@bsg.com.ar>
This is the error message that BachtMailer throws:
"Too many successive failures. BatchMailer is configured to allow no more than 10 successive failures."

And this is the error that Swift throws each of that "successive failures":
"There was a problem reading line 1 of an SMTP response. The response so far was:<br />[]. It appears the connection has died without saying goodbye to us! Too many emails in one go perhaps? (fsockopen: #0) "

So, here I have 3 errors with the same address... but the BachtMailer process didn't add it to "failedRecipients" and continued with the next one.

Do you know what is happenning ??
:banghead:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Difference between errors on sending massive email

Post by Chris Corbyn »

Looks like the SMTP server is hanging up whenever you try to send to silvio.storani@bsg.com.ar... It does look a bit odd. Every time it tries to say "Hey, I wanna send an email to silvio.storani@bsg.com.ar" the SMTP server either:

a) Doesn't respond
b) Closes the connection immediately.

I just tried it:

Code: Select all

220 ServerMail.ns20 ESMTP
EHLO localhost
250-smtp177.allytech.com Hello my-ip-address.vic.bigpond.net.au [58.160.93.XXX], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE 30000000
250-DSN
250-DELIVERBY
250 HELP
MAIL FROM: <envio@bbg-mail.net>
250 2.1.0 <envio@bbg-mail.net>... Sender ok
RCPT TO: <silvio.storani@bsg.com.ar>
450 4.4.0 <silvio.storani@bsg.com.ar>... Can not check MX records for recipient host bsg.com.ar
 
There was a really long delay (maybe 5 seconds) between the RCPT TO command being sent and the 450 response coming back. I suspect that's causing Swift to think there's no answer.

It also seems that the reason for the really long delay is because the SMTP server is trying to do a MX lookup at RCPT time. This is fairly common but the lag suggests the nameservers it's using are busy.
daneel
Forum Newbie
Posts: 19
Joined: Wed Apr 09, 2008 3:39 pm

Re: Difference between errors on sending massive email

Post by daneel »

Alright... so, can I tell swift to wait a bit longer ??

(THANKS again for your help ! )
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Difference between errors on sending massive email

Post by Chris Corbyn »

daneel wrote:Alright... so, can I tell swift to wait a bit longer ??

(THANKS again for your help ! )
It's more related to fsockopen() than Swift. Does it only happen when you're sending a lot of mail or does it happen with just a single address?
daneel
Forum Newbie
Posts: 19
Joined: Wed Apr 09, 2008 3:39 pm

Re: Difference between errors on sending massive email

Post by daneel »

It seems to happen with some addresses, not always...

I saw that Swift_Connection_SMTP has a "timeout" option, and I also saw that is set to 15 seconds... so, if you say it took 5 seconds, that shouldn't bee a problem.

Anyway, I'm setting timout to 60, to see what happens.
daneel
Forum Newbie
Posts: 19
Joined: Wed Apr 09, 2008 3:39 pm

Re: Difference between errors on sending massive email

Post by daneel »

Another question... how could you do this ?

# 220 ServerMail.ns20 ESMTP
# EHLO localhost
# 250-smtp177.allytech.com Hello my-ip-address.vic.bigpond.net.au [58.160.93.XXX], pleased to meet you
# 250-ENHANCEDSTATUSCODES
# 250-PIPELINING
# 250-8BITMIME
# 250-SIZE 30000000
# 250-DSN
# 250-DELIVERBY
# 250 HELP
# MAIL FROM: <envio@bbg-mail.net>
# 250 2.1.0 <envio@bbg-mail.net>... Sender ok
# RCPT TO: <silvio.storani@bsg.com.ar>
# 450 4.4.0 <silvio.storani@bsg.com.ar>... Can not check MX records for recipient host bsg.com.ar

When I tried by telnet, I got an "550 Relaying denied. IP name possible forged".
And also, is there a way with swift to know what was the server's response ? (I mean, it could be nice to save that "450 Can not chexk MX.." to advice the user (that was what I meant with being able to difference errors).
daneel
Forum Newbie
Posts: 19
Joined: Wed Apr 09, 2008 3:39 pm

Re: Difference between errors on sending massive email

Post by daneel »

Chris why did you abadon me !! :cry:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Difference between errors on sending massive email

Post by Chris Corbyn »

Sorry, it wasn't intentional.

I didn't do anything other than what you see. It gave me a 450 response when connecting from Melbourne. Relaying denied is the message you get when the server isn't for outgoing mail or it requires authentication first.

There's not much more I can tell you really. The server is not responding at times by the sound of it, and judging by the amount of time it took for me to get a response from it it' probably a really busy server. Have you spoken to your ISP?

There's currently no way to get the server's response without writing a plugin. With a plugin you can create a ResponseListener to pick up the response :)
Post Reply