gpt4 book ai didi

PHP 邮件发送给多个收件人

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:00:54 24 4
gpt4 key购买 nike

我有一些 PHP 代码,用于将电子邮件发送到特定的电子邮件地址。但是,我想在 PHP 发送邮件时包含更多的电子邮件地址。当我尝试显示以下内容时

错误:邮件程序错误:您必须至少提供一个收件人电子邮件地址。

代码

include "class.phpmailer.php"; // include the class file name
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
//$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "mail.authsmtp.com";
$mail->Port = "25"; // or 587
$mail->IsHTML(true);
$mail->Username = "xxxxx";
$mail->Password = "xxxxx";
$mail->SetFrom("cpn@xxxxxxx.com");
$mail->Subject = $sub1;
$mail->Body = $text_mail;
$mail->AddAddress("xxxxxxx@gmail.com;aral@xxxxxx.com;akhader@xxxxxx.com");
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}
else{
echo "Message has been sent";
}

谁能指导我怎么做

最佳答案

改变这一行

$mail->AddAddress("xxxxxxx@gmail.com;aral@xxxxxx.com;akhader@xxxxxx.com");

为此:

$mail->AddAddress("xxxxxxx@gmail.com");
$mail->AddAddress("aral@xxxxxx.com");
$mail->AddAddress("akhader@xxxxxx.com");

您可以多次运行该函数,直到获得所需的所有地址。

See Here for more info

关于PHP 邮件发送给多个收件人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21183617/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com