BCC's

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
envyum
Forum Newbie
Posts: 5
Joined: Sun Apr 26, 2009 3:52 am

BCC's

Post by envyum »

Heya!
Im trying to send some BCC's through emails gotten from my database.

I made an array out of the emailadresses and names like this:

Code: Select all

 
$qry = "SELECT N.*, U.* FROM hk_notificaties N, hk_users_DNT U WHERE N.notiID=1 AND N.onoff=1 AND U.userID=N.userID";
        $res = mysql_query($qry);
        $to=array();
        while($r = mysql_fetch_array($res)){
            $to[$r['email']]=$r['name'];
        }
 
Now when i use my swiftmailer with setTo like seen below it works properly, and he send all the e-mails.:

Code: Select all

 
require_once('lib/swift_required.php');
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance()
    ->setSubject('xxxx')
    ->setFrom(array('noreply@xxx.nl' => 'xxx'))
    ->setTo($to)
    ->setBody('text!')
    ->addPart('text', 'text/html');
$result = $mailer->Send($message);  */            
 
But when i change the setTo to setBcc or addBcc or whatever, i get the error about unknown function getFieldBody();

Code: Select all

 
Fatal error: Call to a member function getFieldBody() on a non-object in /var/www/vhosts/xxxx.nl/httpdocs/lib/classes/Swift/Transport/MailTransport.php on line 143
 
And when i change Send to Batchsend i get

Code: Select all

 
Warning: Invalid argument supplied for foreach() in /var/www/vhosts/xxxx.nl/httpdocs/lib/classes/Swift/Mailer.php on line 143
 
Anyone knows what goes wrong here?

Thanks in advance
envyum
Forum Newbie
Posts: 5
Joined: Sun Apr 26, 2009 3:52 am

Re: BCC's

Post by envyum »

BUMP!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: BCC's

Post by Chris Corbyn »

Hmm... sounds like a bug. Let me check that.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: BCC's

Post by Chris Corbyn »

It does look like this is a bug, however what you're trying to do will not work. Swift Mailer won't allow you to Bcc all recipients without having any To: recipients. Set your own email-address as the To: recipient or something like that.

I could (read, should) default to "undisclosed-recipients:;" but right now that's not supported.
envyum
Forum Newbie
Posts: 5
Joined: Sun Apr 26, 2009 3:52 am

Re: BCC's

Post by envyum »

->setTo('timen@envyum.nl', 'timen')
->setBcc($to)

Will not send all the recipients an email.
When i set the BCC to my own email it does.

So does my $to array work for this?

Code: Select all

 
while($r = mysql_fetch_array($res)){
     $to[$r['email']]=$r['name'];
}
 
envyum
Forum Newbie
Posts: 5
Joined: Sun Apr 26, 2009 3:52 am

Re: BCC's

Post by envyum »

BUMP!!
envyum
Forum Newbie
Posts: 5
Joined: Sun Apr 26, 2009 3:52 am

Re: BCC's

Post by envyum »

*sigh*

BUMP!
Post Reply