Error handling

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
kangus
Forum Newbie
Posts: 2
Joined: Fri May 24, 2002 12:05 pm

Error handling

Post by kangus »

:D
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?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

It does if you view the source ;)

The address is wrapped in < and > tags so it gets parsed in HTML ;)
kangus
Forum Newbie
Posts: 2
Joined: Fri May 24, 2002 12:05 pm

Post by kangus »

feyd | Please use

Code: Select all

,

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

,

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]
Post Reply