log failed errors

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
phait
Forum Commoner
Posts: 46
Joined: Wed Apr 07, 2004 4:41 am
Location: watford / leicester, UK

log failed errors

Post by phait »

hi,
Just wanted to confirm something and ask for advice to mitigate it if possible.

I have to send a newsletter to about 10K addresses each month. I would like to capture all the initial failures like so:

Code: Select all

... sending stuff here...

$failed = $swift->log->getFailedRecipients();

if ($sent) {
    echo("******************** MAILS SENT ********************\n");
    echo("Total of $sent mails sent to recipient\n\n");
}

if (0 < count($failed)) {
    echo("******************** MAILS NOT SENT ********************");
    echo("Total of ".count($failed)." mails were not sent\n");
    foreach($failed as $email) {
        echo("$email\n");
    }
}
but AIUI, all the mails in the queue would have to be sent before I could get a full count.

This may take some time with the amount being sent and a php process would be sitting there waiting for the result, so apart from the obvious answers of "get more ram / faster machine etc", is there any tips on how to speed up the processing to get the failed count in a quicker time?

I'm using the Sendmail Connection as it gives me better results than the NativeMail connection. The box is running Debian Sarge and the script is executed via the CLI.

thanks for your time and any (sensible) advice given,
Paul
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You'd have to wait for the full batch to be sent before you can get the failures yes.

If you're looking for the entire fail count it goes without saying that you have to send them first otherwise Swift will never know what worked and what didn't :? If you want a more verbose solution whereby you get the failures on a per-address basis in realtime, you can use the VerboseSending plugin with your own View (just don't ouptut anything in the view):

http://www.swiftmailer.org/wikidocs/v3/plugins/verbose

Be sure to read the end of the page which explains how to create your own view. Just don't output anything in it, even if this is semantically wrong. l'll change the name at some point so it's not so rigid :)
phait
Forum Commoner
Posts: 46
Joined: Wed Apr 07, 2004 4:41 am
Location: watford / leicester, UK

Post by phait »

hey chris,
thanks for the reply. I'll have a butchers a the page referenced... and thanks for just confirming what I thought would need to happen.

paul
Post Reply