在 PHP Mailer 中添加 CC 不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25153870/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 17:41:41  来源:igfitidea点击:

Add CC in PHP Mailer not working

php

提问by ling

Im trying to send on email to user using AddAddress and another three emails to admin and so on by CC .
I can send out email using AddAdress() But not using Add CC.
Below is my code.

我尝试使用 AddAddress 向用户发送电子邮件,并通过 CC 向管理员发送另外三封电子邮件,依此类推。
我可以使用 AddAdress() 发送电子邮件,但不能使用 Add CC。
下面是我的代码。

<?php
require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();  // telling the class to use SMTP
$mail->Host     = "mail.test.com.my"; // SMTP server

$mail->From     = "[email protected]";
$mail->AddAddress($email);

$mail->Subject  = "Colourful email";
$mail->Body     =$message;
/*$mail->WordWrap = 50;*/
$mail->AddCC    =($email_1);
$mail->AddCC    =($email_2);
$mail->AddCC    =($email_3);

if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Kindly check your email for the confirmation of your rental.Thank you.';
}

?>

回答by TBI

You dont need to =in this

你不需要=在这个

$mail->AddCC($email_1);

回答by Sudharsun

Try with this additional parameter

尝试使用此附加参数

$mail->AddCC('[email protected]', 'Person One');
$mail->AddCC('[email protected]', 'Person Two');