3

I have a problem, when I want to send mail to a customer and also to the admins.

The problem is, that the customer receives the mail, but the bcc will not if the from = bcc. Is there any setting I have missed? Could this be a server issue, or a Zend related one?

Example code I use:

$mail = new Zend_Mail();
$mail->setFrom( 'admin@example.com', 'Admin' )
->addTo( 'customer@anydomain.com', 'Customer' )
->setBodyText( 'Example' )
->addBcc('admin@example.com');

$mail->send();

The headers are (from $mail->getHeaders()):

array(3) {
  ["From"]=>
  array(2) {
    [0]=>
    string(26) "Admin <admin@example.com>"
    ["append"]=>
    bool(true)
  }
  ["To"]=>
  array(2) {
    [0]=>
    string(25) "Customer <customer@anydomain.com>"
    ["append"]=>
    bool(true)
  }
  ["Bcc"]=>
  array(2) {
    [0]=>
    string(18) "admin@example.com"
    ["append"]=>
    bool(true)
  }
}
Gergely Havlicsek
  • 1,581
  • 1
  • 19
  • 29
  • To begin with, you should quote your email addresses, i.e. `$mail->setFrom('admin@example.com')`, if it's not a typo in your question. – dinopmi Sep 20 '11 at 07:55
  • Sorry, it was just typo, the main question is why the admin is not receiveing the bcc mail if it was sent by him. I will correct the example. – Gergely Havlicsek Sep 20 '11 at 08:05
  • Can you please see the header information and paste it here? That will help us investigate further. You can get mail-header by calling `$mail->getHeaders()` method. – Rakesh Sankar Sep 20 '11 at 10:03
  • @RakeshS I have updated the question with the headers info! – Gergely Havlicsek Sep 20 '11 at 10:22

4 Answers4

1

I stumbled on this post while working on using Zend_Mail to send a bcc to the sender address and found that for me the following does in fact work:

$fromName = 'admin';
$fromMail = 'sender@mail.com';

$mail = new Zend_Mail();
$mail->setFrom($fromEmail, $fromName);
$mail->addBcc($fromMail);

Even though the bug report http://framework.zend.com/issues/browse/ZF-8723 as linked in RakeshS's post is still marked as unresolved. My Zend version is:

const VERSION = '1.11.12';

It would be interesting to learn whether the problem would also be solved for the original posters for the updated Zend framework, if they may happen to read this

Pankrates
  • 3,074
  • 1
  • 22
  • 28
1

I'm getting the same behavior as you. The sender is not getting the message if the address is added as Bcc. So, it's likely to be a Zend Mail related issue (I don't think we have the same server configuration).

dinopmi
  • 2,683
  • 19
  • 24
1

There is a bug added to ZF which almost similar to this issue: http://framework.zend.com/issues/browse/ZF-8723

BTW, you could also get BCC to work with the help of Zend Mail Add Header method. Please try the following work-around:

$mail->addHeader('Bcc', 'admin@example.com');
Rakesh Sankar
  • 9,337
  • 4
  • 41
  • 66
  • Thanks Rakesh, I have tried, but the server gives a 500 error. Although it would be a good workaround, it seems to me that this is not working. Maybe there is a different way of injecting the header. – Gergely Havlicsek Sep 20 '11 at 11:56
  • I have tried it like this: $mail->addHeader('bcc: admin@example.com'); But it will send the letter 2 times to the original recipient (customer). – Gergely Havlicsek Sep 20 '11 at 12:01
  • 1
    If you are using this, then you shouldn't use `addBcc()` method. I hope you ain't using it. – Rakesh Sankar Sep 20 '11 at 12:07
  • It seems that this version is able to send the mail to the addresses correctly, but puts the header info into the mail body: $mail->addHeader("Bcc: admin@example.com\r\n"); If I could correct this, then it would be perfect... :) – Gergely Havlicsek Sep 20 '11 at 12:22
  • May be it thinks its something different, can you try this: `$mail->addHeader('bcc: admin@example.com', '', true);` and see what happens? – Rakesh Sankar Sep 20 '11 at 12:25
0

if you use only Bcc recipients without TO read this

http://framework.zend.com/issues/browse/ZF-3509

pe4k
  • 14
  • 1
  • Note that [link-only answers](http://meta.stackoverflow.com/tags/link-only-answers/info) are discouraged, SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference. – kleopatra Oct 14 '13 at 15:14
  • Please read the question first, there is a TO recipient in my example. The problem is when the FROM = BCC. – Gergely Havlicsek Oct 15 '13 at 10:19