Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP SMTP BCC, not going through

Tags:

php

email

smtp

bcc

Recipients named in the BCC/CC (in the headers) are not received. I've found a couple of posts with similar questions, no answers...

The code is below, the question is: "Have any of you had similar problems?"

require_once "Mail.php";

$host = "mail.mailserver.com";
$username = "[email protected]";
$password = "getyourownpassword";

$headers = array ('From' => "User Name <$username>",
                  'To' => $to_,
                  'Cc' => 'Patty <[email protected]>',
                  'Subject' => $subj_,
                  'Content-type' => 'text/html');

$smtp = Mail::factory('smtp',
                      array ('host' => $host,
                             'auth' => true,
                             'username' => $username,
                             'password' => $password));

$mail = $smtp->send($to_, $headers, $mail_msg);
like image 642
Weston Watson Avatar asked Dec 13 '25 22:12

Weston Watson


1 Answers

It looks like you're using the PEAR mail module. if you read here You'll see a discussion about the headers passed to the pear module only specifies how the message looks, not to who actually gets it. If you add a CC header, that person will show up as being CC'd but to actually receive it he needs to be added to the recipients array. For BCC, you add them to recpients array, but don't show them in the header.

like image 177
superfro Avatar answered Dec 16 '25 10:12

superfro