Dealing with failed recipients

SMTP does occassionally reject recipient addresses due to malformity, domain conflicts, DNS issues and other problems. If you want to track who got rejected you should enable Swift's logging facility so that these failures can be collected. The failed addresses will be stored in $swift→log→getFailedRecipients() as an array.

$swift =& new Swift(new Swift_Connection_SMTP("host.tld"));
$swift->log->enable();
 
$message =& new Swift_Message("My subject", "My body");
 
$recipients =& new Swift_RecipientList();
$recipients->addTo("foo@bar");
$recipients->addTo("zip@button.tld", "Zip");
 
$num_sent = $swift->send($message, $recipients, "me@my-domain.com");
 
echo "Message sent to $num_sent of 2 recipients";
 
echo "Failed recipients:<br />";
echo implode(" ,", $swift->log->getFailedRecipients());
 
v3/sending/failed_recipients.txt · Last modified: 2009/03/03 06:41 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki