Phpmailer AddBcc not working

匿名 (未验证) 提交于 2019-12-03 08:35:02

问题:

I am using phpmailer to sent email, and it works the recipients receive the mail except the bcc and cc details is not showing the mail. Someone can suggest a solution to this . the code is

require_once("PHPMailer_v5.1/class.phpmailer.php"); require_once("PHPMailer_v5.1/language/phpmailer.lang-en.php");               $mailer = new PHPMailer(); $mailer->IsSMTP();               $mailer->SMTPAuth = true;                    $mailer->SMTPSecure = "tls"; $mailer->Host = 'smtp.gmail.com'; $mailer->Port = 587;                 $mailer->Username = "myuserid"; $mailer->Password = "mypassword"; $mailer->FromName = $fromname; $mailer->From = "myuserid";              $mailer->AddAddress("to@gmail.com",$toname);                 $mailer->Subject = $subject;                 $mailer->Body =$content;                 $mailer->AddCC("something@gmail.com", "bla");                $mailer->AddBCC("foo@gmail.com", "test"); if(!$mailer->Send()) { echo "Message was not sent"; } else echo "mail sent"; 

回答1:

Use as

$mailer->AddBCC("foo@gmail.com", "test"); $mailer->AddCC("something@gmail.com", "bla"); 


回答2:

You never see BCC details. That's what they are BCC details for. Even the recipient of a BCC will not see his own name with the recipients.

PS: You noticed you wrote addBCC instead of AddBCC (capital A)?



回答3:

From the phpMailer function reference:

Adds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

This might be causing your issue.



回答4:

the bcc will never show; only TO and CC

BCC=Blind Carbon Copy



回答5:

PHPMailer not sending CC or BCC

Old question, but I ended up here looking for an answer. Just learned elsewhere that those functions AddCC and AddBCC only work with win32 SMTP

Try using:

$mail->addCustomHeader("BCC: mybccaddress@mydomain.com"); See http://phpmailer.worxware.com/?pg=methods

Hope this helps someone, cheers!



回答6:

$email->addBCC('my@email.com', 'My Name'); 

See PHPMailer.php (current version 6.0.5) on line 934 (https://github.com/PHPMailer/PHPMailer/blob/master/src/PHPMailer.php#L934):

/**  * Add a "BCC" address.  *  * @param string $address The email address to send to  * @param string $name  *  * @return bool true on success, false if address already used or invalid in some way  */ public function addBCC($address, $name = '') {     return $this->addOrEnqueueAnAddress('bcc', $address, $name); } 


回答7:

$ mail-> AddCC (""); $ mail-> AddBCC ("mail @ domain") 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!