Page 1 of 1

BCC's

Posted: Sun Apr 26, 2009 3:58 am
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

Re: BCC's

Posted: Thu Apr 30, 2009 2:26 am
by envyum
BUMP!

Re: BCC's

Posted: Sat May 02, 2009 5:41 am
by Chris Corbyn
Hmm... sounds like a bug. Let me check that.

Re: BCC's

Posted: Sat May 02, 2009 5:46 am
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.

Re: BCC's

Posted: Sun May 03, 2009 3:53 am
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'];
}
 

Re: BCC's

Posted: Fri May 08, 2009 2:53 am
by envyum
BUMP!!

Re: BCC's

Posted: Fri May 15, 2009 11:58 am
by envyum
*sigh*

BUMP!