Page 1 of 1
swiftmailer keeps crashing after sending +/- 5 emails...
Posted: Tue Mar 11, 2008 12:11 pm
by coderb
Hi,
I'm runnng a script that send builds each html email individually and attaches a different jpg on each email then sends.
so far it only gets to successfully send about 5 to 10 emails (with or without attachments, before it crashes with this error:
Fatal error:
Uncaught Error of type [swift_connectionexception] with message [There was a problem reading line 1 of an SMTP response. The response so far was:
[]. It appears the connection has died without saying goodbye to us! Too many emails in one go perhaps? (fsockopen: #0) ]
@0 swift::swift() in /Library/WebServer/Documents/adco/flow/13_1_emailx.php on line 131
@1 swift::connect() in /usr/include/php/SWIFT/Swift.php on line 109
@2 swift::handshake() in /usr/include/php/SWIFT/Swift.php on line 230
in /usr/include/php/SWIFT/Swift/Errors.php on line 99
I get the same error on php5
Any help would be greatly appreciated. thanks
Re: swiftmailer keeps crashing after sending +/- 5 emails...
Posted: Tue Mar 11, 2008 8:37 pm
by Chris Corbyn
Whatever SMTP server you're using is closing the connection on you. Suspiciously after 5 emails it seems from this and from another thread you created.... What server is and what host? The host may have some extremely rigid policy of 5 emails for connection?
You could try using the AntiFlood plugin to get around that.
Re: swiftmailer keeps crashing after sending +/- 5 emails...
Posted: Tue Mar 11, 2008 10:39 pm
by coderb
thanks for your response.
we're using Time Warner Cable (buisness), i've sent them an email to ask about restrictions, but still waiting for a response.
However, I have been able to send up to 10 emails in one go, but without attachments, around 5 with attachments, so it seems to me to be a size restriction rather than number.
where this restriction occurs is the question.
my php.ini settings are:
max_execution_time = 500 ; Maximum execution time of each script, in seconds
max_input_time = 500 ; Maximum amount of time each script may spend parsing request data
memory_limit = 16M
but the error/crash occurs before the time limit. Would lack of available memory cause these errors in any way? is there maybe another setting that I'm missing somewhere?
Also, inside each email build loop I'm creating a new smtp connection.
I realize this isn't ideal for large batches, but in our case each email's html content and attachment is completely different.
we'll only send max 100 at a time. would it still be better to use one of the plugins, maybe the anti-flood? (although we're still on php4)
if so, please can you explain how/where I should incorporate the loop in this case.
thanks again,
Re: swiftmailer keeps crashing after sending +/- 5 emails...
Posted: Tue Mar 11, 2008 10:52 pm
by Chris Corbyn
If it were lack of memory you'd be getting a different error... but just to 100% rule out memory issues, how big are the attachments you're sending? Without using disk caching you need roughly:
Required memory = <attachment size> + ((<attachment size> / 3) * 4) + 1,000,000 bytes
It's a very rough estimate, but enough to give you an idea.
With disk caching combined with the use of Swift_File to add the attachment, you need:
Required memory = ~1,000,000 bytes
Give or take say 500KB.
Disk caching hugely reduces memory usage by doing all the encoding in files rather than in memory.
Re: swiftmailer keeps crashing after sending +/- 5 emails...
Posted: Tue Mar 11, 2008 10:53 pm
by Chris Corbyn
Ah, hang on, you're creatig new connections repeatedly? Are you closing the connection each time? Swift makes persistent connections so you may be hitting a connection limit.
Re: swiftmailer keeps crashing after sending +/- 5 emails...
Posted: Wed Mar 12, 2008 2:05 pm
by coderb
hi Chris,
I think it was a connection thing, I changed it to connect outside the loop with antiflood set to 5,5.
(will change the antiflood params, but just testing).
I now don't get the errors anymore.
however, it may have been a restriction lifted by the isp, but still have to see if they sent an email response (via a work collegue).
now all I have to change (I think) is my apache connection timeout from 300, since script runs for longer than 5 minutes. my php.ini max times are okay.
Is this apache connection timeout setting a common setting to change or am I doing something else wrong perhaps?
thanks again,
Re: swiftmailer keeps crashing after sending +/- 5 emails...
Posted: Wed Mar 12, 2008 10:59 pm
by Chris Corbyn
For scripts which run for a long time you're usually better of executing them via the command line. However, there is the ignore_user_abort() function which makes a script keep running when you close the browser window.