PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Jul 22, 2017 3:33 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Jan 09, 2013 4:29 am 
Offline
Forum Newbie

Joined: Wed Jan 09, 2013 4:08 am
Posts: 1
Hey,

I'm want to use swift mailer to send some mails at the same time.
But it doesent work :(

Syntax: [ Download ] [ Hide ]
foreach($id as $key => $value){
    if($value[1]=="on" && $value[2] !=""){
        $message = Swift_Message::newInstance($betreff)
            ->setFrom(array($row['email'] => $_SESSION['vname']." ".$_SESSION['nname']))
            ->setTo(array($value[2]))
            ->setBody($mailtext)
            ->setReturnPath($row['email'])
            ->setContentType("text/html")
        ;
       
        $transport = Swift_MailTransport::newInstance();
        $mailer = Swift_Mailer::newInstance($transport);
       
        if($mailer->send($message)){
            echo "OK";
        }else{
            echo "ERROR";
        }
       
    }
}  


The email adresses are in $id, exactly in $value[2].

Im always getting this error below:
Syntax: [ Download ] [ Hide ]
Fatal error: Uncaught exception 'Swift_RfcComplianceException' with message 'Address in mailbox given [] does not comply with RFC 2822, 3.6.2.'
in .../swift/lib/classes/Swift/Mime/Headers/MailboxHeader.php:352
Stack trace:
#0 .../swift/lib/classes/Swift/Mime/Headers/MailboxHeader.php(264): Swift_Mime_Headers_MailboxHeader->_assertValidAddress('')
#1 .../swift/lib/classes/Swift/Mime/Headers/MailboxHeader.php(108): Swift_Mime_Headers_MailboxHeader->normalizeMailboxes(Array)
#2 .../swift/lib/classes/Swift/Mime/Headers/MailboxHeader.php(65): Swift_Mime_Headers_MailboxHeader->setNameAddresses(Array)
#3 .../swift/lib/classes/Swift/Mime/SimpleMimeEntity.php(588): Swift_Mime_Headers_MailboxHeader->setFieldBodyModel(Array)


Where is the problem and how can i fix it?
I cant send the mails as one mail with all the adresses at once, because i need to check if every mail was sent or not.

Thanks ;)


Top
 Profile  
 
PostPosted: Tue Feb 05, 2013 3:44 am 
Offline
Forum Newbie

Joined: Tue Feb 05, 2013 3:26 am
Posts: 3
maybe you can find a solution in my code :) and maybe you can help me too

viewtopic.php?f=52&t=137349


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

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


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:  
cron
Powered by phpBB® Forum Software © phpBB Group