Page 1 of 1
Error handling
Posted: Wed Dec 06, 2006 11:28 am
by kangus
We have a working setup and have been testing batch mail but we needed to log all bad e-mail address to groom the e-mail list. We tried:
Code: Select all
----- all the setup and mail stuff then -------
print_r($mailer->transactions);
print('<br>Errors:<br>');
print_r($mailer->errors);
print('<br>Failed E-mail Address:<br>');
print_r($mailer->getFailedRecipients());
which produced:
Code: Select all
Array ( [command] => MAIL FROM: [time] => 0.18734100 1165425565 [response] => 250 ok ) [17] => Array ( [command] => RCPT TO: [time] => 0.27666900 1165425565 [response] => 511 sorry, can't find a valid MX for rcpt domain (#5.1.1 - chkuser) ) [18] => Array ( [command] => RSET [time] => 0.38277400 1165425566 [response] => 250 flushed ) [19] => Array ( [command] => QUIT [time] => 0.46309200 1165425566 [response] => 221 Welcome to Qmail Toaster Ver. 1.3 smtp Server ) )
Errors:
Array ( [0] => Array ( [num] => -1 [time] => 0.46286800 1165425566 [message] => Send Error: Sending to 1 recipients rejected (bad response code). ) )
Failed E-mail Address:
Array ( [0] => )
The bad address is the last address of the recipients array, Errors knows there is an error but the transactions data does not contain the e-mail address nor does the getFailed Recipient.
We are using the latest version of Qmail on the server with PHP4.3.9.
Any ideas?
Posted: Wed Dec 06, 2006 11:35 am
by Chris Corbyn
It does if you view the source
The address is wrapped in < and > tags so it gets parsed in HTML

Posted: Wed Dec 06, 2006 12:36 pm
by kangus
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
SO:
Code: Select all
print('<br>Failed E-mail Address:<br>');
$badAddress=$mailer->getFailedRecipients();
foreach($badAddress as $key=>$val)
{
print(preg_replace("|([<>])|","",$val));
}
gets me what I needed..
Thanks
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]