PHP Developers Network
http://forums.devnetwork.net/

Problem with sending some mails at once
http://forums.devnetwork.net/viewtopic.php?f=52&t=137249
Page 1 of 1

Author:  alexd1991 [ Wed Jan 09, 2013 4:29 am ]
Post subject:  Problem with sending some mails at once

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 ;)

Author:  bennot [ Tue Feb 05, 2013 3:44 am ]
Post subject:  Re: Problem with sending some mails at once

maybe you can find a solution in my code :) and maybe you can help me too

viewtopic.php?f=52&t=137349

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/