PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Oct 15, 2018 9:05 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Nov 17, 2009 8:07 am 
Offline
Forum Newbie

Joined: Tue Nov 17, 2009 7:35 am
Posts: 1
Hi

I am using the good swift mailer (4.0.5) to loop through a mysql table, and by each email address I'm checking if the mail was sent - If so: mark it as ok/sent in the database.

Is there any way to suppress realtime errors (Uncaught exception) that stops my loop?
I have tried @$mailer->send($message) but it doesnt work.

Hope someone can guide me a bit. Thank you.


Syntax: [ Download ] [ Hide ]
<?php
 
require_once 'lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance($smtphost, 25)
;
$mailer = Swift_Mailer::newInstance($transport);
$mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100));
$message = Swift_Message::newInstance()
->setSubject($mailsubject)
->setFrom($servermailhost)
->setReplyTo($servermailhost)
->setReturnPath($servermailbounce)
->setBody($mailtext)
->setCharset('iso-8859-1')
;
 
//ArrayLogger
$logger = new Swift_Plugins_Loggers_ArrayLogger();
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
 
$linkresult = @mysql_query("SELECT * FROM maillist WHERE sentcheck=0 ORDER BY timestamp DESC");
if (@mysql_num_rows($linkresult) > 0) {
 
while ($nrow = @mysql_fetch_array($linkresult)) {
 
    $bid = $nrow['id'];
    $bname = $nrow['thename'];
    $bemail = $nrow['theemail'];
    if (strlen($bname)>1) {
    $message->setTo($bemail, $bname);
    } else {
    $message->setTo($bemail);
    }
 
if ($mailer->send($message)) {
@mysql_query ("UPDATE maillist SET sentcheck=1 WHERE id=$bid LIMIT 1");
}
 
}
 
@mysql_query("UPDATE newsletters SET sentstatus='".$logger->dump()."' WHERE id=$newsletterid");
header ('Location: '.$root.'newsletter/sentok/');
 
}
 
?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group