several BCC addresses

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
uyuni
Forum Newbie
Posts: 7
Joined: Wed Feb 11, 2009 12:05 pm

several BCC addresses

Post by uyuni »

When I add several BCC-addresses:
$recipients->addBcc('aa@bb.cc');
$recipients->addBcc('dd@ee.ff');

then in the SMTP-header they appear on separate lines. Shouldn't they appear all on one line?
When the mail is sent only the first BCC-address is receiving the mail!

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

Re: several BCC addresses

Post by Chris Corbyn »

BCC addresses should not see each others' addresses. They should only see their own, so there should just be one Bcc: line in each email.
uyuni
Forum Newbie
Posts: 7
Joined: Wed Feb 11, 2009 12:05 pm

Re: several BCC addresses

Post by uyuni »

It must be possible to send an email to several BCC addresses.
I suppose the mail header should look like this:

Bcc: aa@bb.cc, dd@ee.ff

But when I have this code
$recipients->addBcc('aa@bb.cc');
$recipients->addBcc('dd@ee.ff');

the header looks this way:
Bcc: aa@bb.cc,
dd@ee.ff

And obviously the SMTP-server doesn't understand the newline and the BCC is only sent to aa@bb.cc and not to dd@ee.ff.

This seems a bug to me.

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

Re: several BCC addresses

Post by Chris Corbyn »

uyuni wrote:It must be possible to send an email to several BCC addresses.
I suppose the mail header should look like this:

Bcc: aa@bb.cc, dd@ee.ff

But when I have this code
$recipients->addBcc('aa@bb.cc');
$recipients->addBcc('dd@ee.ff');

the header looks this way:
Bcc: aa@bb.cc,
dd@ee.ff

And obviously the SMTP-server doesn't understand the newline and the BCC is only sent to aa@bb.cc and not to dd@ee.ff.

This seems a bug to me.

Emilio
If both Bcc recipients are in the same Bcc header then the entire point of Bcc has been violated and RFC 2822 has not been conformed to.

What Swift mailer *should* be doing is sending *two* separate emails that have differing headers:

Bcc: address1@domain.com

AND in a separate email

Bcc: address2@domain.com

Are you saying that Swift Mailer is showing both addresses in the headers? Can you please post the full code you are using?
uyuni
Forum Newbie
Posts: 7
Joined: Wed Feb 11, 2009 12:05 pm

Re: several BCC addresses

Post by uyuni »

This is my code:

Code: Select all

$recipients->addBcc('aa@bb.cc');
$recipients->addBcc('dd@ee.ff');
There is one email sent and in the file MailSend.php in the funtion sendPerformed I log the headers before they are used in the mail-function:

Code: Select all

Return-Path: <info@xxx.com>
From: Name <info@xxx.com>
Bcc: aa@bb.cc,
dd@ee.ff
Reply-To: Name <info@xxx.com>
Date: Thu, 12 Feb 2009 07:43:08 +0100
X-LibVersion: 3.3.2
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="_=_swift-231224993c4fcb495f6.37827623_=_"
Content-Transfer-Encoding: 7bit
Message-ID: <20090212064308.5904.1718430715.swift@xxx.com>
This seems wrong and does not work correctly.

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

Re: several BCC addresses

Post by Chris Corbyn »

I need to see more code. When you say in beforeSendPerformed() you logged the headers, what code did this, and what Connection type were you using? :)

Also, are you using send() or batchSend()?
uyuni
Forum Newbie
Posts: 7
Joined: Wed Feb 11, 2009 12:05 pm

Re: several BCC addresses

Post by uyuni »

File MailSend.php:

Code: Select all

 
  public function doMail($to, $subject, $message, $headers, $params)
  {
    $original_from = @ini_get("sendmail_from");
    @ini_set("sendmail_from", $this->returnPath);
    
    $headers = $headers->build();
 
[color=#FF0000]>>> here I did: var_dump($headers)[/color]
    if (!ini_get("safe_mode")) $success = mail($to, $subject, $message, $headers, $params);
    else $success = mail($to, $subject, $message, $headers);
 
    if (!$success)
    {
      @ini_set("sendmail_from", $original_from);
      throw new Swift_ConnectionException("Sending failed using mail() as PHP's default mail() function returned boolean FALSE.");
    }
    @ini_set("sendmail_from", $original_from);
  }
 
I used

Code: Select all

[color=#FF0000]$swift->send[/color]
Emilio
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: several BCC addresses

Post by Chris Corbyn »

Ok, so you're correct that if you're using the NativeMail connection, Swift does build all Bcc addresses into one header. That's because mail() requires it. You're also correct that Swift is splitting the addresses onto multiple lines. What I'm not sure you're entirely correct about is the use of whitespace. Swift should be doing this:

Code: Select all

Bcc: address1@domain.com,
 address2@domain.com
Notice the space (or tab) on the second line? That makes it parts of the same header. If it's not doing this (and you're 100% that it's not) then this is a bug. If it's doing this, then that is the 100% expected behaviour (in version 3).
uyuni
Forum Newbie
Posts: 7
Joined: Wed Feb 11, 2009 12:05 pm

Re: several BCC addresses

Post by uyuni »

Then your code and the header is correct.

Unfortunately the SMTPserver of my provider does not understand this and sends the mail only to the first BCC.

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

Re: several BCC addresses

Post by Chris Corbyn »

uyuni wrote:Then your code and the header is correct.

Unfortunately the SMTPserver of my provider does not understand this and sends the mail only to the first BCC.

Emilio
That is definitely a bug with the server in which case, and not with Swift Mailer. Can you be 100% that the other address is not being rejected by the server? I mean, have you tried swapping the addresses around? It's unlikely to be because the second one is on a new line... it's more likely that the domain name of it is being rejected, or that the email is being blocked as spam for that particular recipient.
Post Reply