Page 1 of 1

no error in getFailedRecipients

Posted: Wed Jan 16, 2008 2:50 am
by bobobobo
hi,
i've a problem with this code:

Code: Select all

<?
$swift =& new Swift(new Swift_Connection_SMTP("localhost"));
$swift->attachPlugin(new Swift_Plugin_AntiFlood(1, 10), "anti-flood");
//Make the script run until it's finished in the background
set_time_limit(0); ignore_user_abort();
echo "<font color=\"#333333\" face=\"Arial, Helvetica, sans-serif\" size=\"+1\">Invio newsletter in corso...</font><br>";
flush(); ob_flush();
 
$message =& new Swift_Message("My subject", "My body");
 
$recipients = new Swift_RecipientList(); 
$recipient = new Swift_Address ("xxx@www.it");
$recipients->addTo ($recipient); 
$recipient = new Swift_Address ("yyy@xxx.it");
$recipients->addTo ($recipient); 
 
$num_sent = $swift->send($message, $recipients, "www@www.com");
echo "<font color=\"#333333\" face=\"Arial, Helvetica, sans-serif\" size=\"+1\">Messaggi inviati: <strong>$num_sent</strong></font><br>";
echo "Failed recipients:<br />";
$log =& Swift_LogContainer::getLog();
$log->setLogLevel(3);
echo "---> ".implode(" ,", $log->getFailedRecipients());
 
$swift->disconnect();
?>
I can correctly send mail to valid address but I get $log->getFailedRecipients() return null when I send to unexisting recipient.
Why?

Another question...
How can I send a single mail to every user in my list? Otherway if I use $recipients->addTo ($recipient); they all see all the address.

Thanks
Bob

Re: no error in getFailedRecipients

Posted: Wed Jan 16, 2008 4:20 am
by Chris Corbyn
Swift only knows what your SMTP server tells it. If the SMTP server accepts the recipient Swift can do nothing more. You'll get a bounced email for these cases.

Re: no error in getFailedRecipients

Posted: Wed Jan 16, 2008 6:12 am
by bobobobo
thanks Chris

can you help me about second question...

How can I send a single mail to every user in my list? Otherway if I use $recipients->addTo ($recipient); they all see all the address.

thanks
Bob

Re: no error in getFailedRecipients

Posted: Wed Jan 16, 2008 7:07 am
by Chris Corbyn
bobobobo wrote:thanks Chris

can you help me about second question...

How can I send a single mail to every user in my list? Otherway if I use $recipients->addTo ($recipient); they all see all the address.

thanks
Bob
batchSend() in place of send().

EDIT | And don't put that in a loop!! Just call batchSend() once.

Re: no error in getFailedRecipients

Posted: Wed Jan 16, 2008 7:23 am
by bobobobo
thanks a lot Chris,
for the precious answer.

Have you any suggestion to let me solve the SMTP settings problem?
I really need to track wich mails are not sent due to typing errors or wrong address.

thanks
Bob