Page 1 of 1

getFailedRecipients()

Posted: Thu Jul 03, 2008 3:02 pm
by bobo79
Hi everyone,
I use swiftmailer version Swift-3.3.2-php5
I want to enable logging to catch the failed addresses.

Code: Select all

<?
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
 
$swift =& new Swift(new Swift_Connection_SMTP("localhost"));
$log =& Swift_LogContainer::getLog();
$log->setLogLevel(4);
 
 
echo '<pre>' . htmlentities($log->dump(true)) . '</pre>';
 
$message =& new Swift_Message("My subject", "My body");
 
$recipients =& new Swift_RecipientList();
$recipients->addTo("aaa@qq q.it");
$recipients->addTo("xxx@yy y.it");
 
$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(" ,", $log->getFailedRecipients());
?>

this is result:

++ Log level changed to 4
Message sent to 2 of 2 recipientsFailed recipients:

where is the prblem, an error

thanks
Bobo

Re: getFailedRecipients()

Posted: Tue Jul 08, 2008 2:56 pm
by sinisa
can't see log records before sending emails. Move line
echo '<pre>' . htmlentities($log->dump(true)) . '</pre>';
before or instead of this line
echo "Message sent to $num_sent of 2 recipients";

Re: getFailedRecipients()

Posted: Wed Jul 09, 2008 2:36 am
by Chris Corbyn
Yes, you're trying to dump the log before Swift has actually done anything. Place the log dump after the sending portion of the script.