简体   繁体   中英

PHP SMTP BCC, not going through

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 = "notification@yourhost.com";
$password = "getyourownpassword";

$headers = array ('From' => "User Name <$username>",
                  'To' => $to_,
                  'Cc' => 'Patty <patty@gmail.com>',
                  '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);

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM