[英]PHPmailer is sending copy to my email
When I'm sending a test message via PHPmailer (SMTP) my email appends to the recepients list. 当我通过PHPmailer(SMTP)发送测试消息时,我的电子邮件将追加到收件人列表中。 Here is what recipient sees in inbox email
这是收件人在收件箱电子邮件中看到的内容
To: mail@mail.com, Name <mail2@mail.com>
收件人:mail@mail.com,名称为<mail2@mail.com>
The second email is mine. 第二封电子邮件是我的。 How can I stop this?
我该如何阻止呢?
Here is my code 这是我的代码
function send_email($to, $fromName, $subject, $message, $contentType='text', $smtp_opts) {
$mail = new PHPmailer();
$mail->SetFrom($smtp_opts['fromEmail'], $fromName);
$mail->Subject = $subject;
$mail->Mailer = 'smtp';
$mail->AddAddress($to);
$mail->CharSet = "UTF-8";
$mail->IsHTML($contentType=='html');
$mail->Host = $smtp_opts['host'];
$mail->SMTPAuth = (bool)$smtp_opts['auth'];
if ($mail->SMTPAuth) {
$mail->Username = $smtp_opts['username'];
$mail->Password = $smtp_opts['password'];
}
$mail->Body = $message;
$mail->AddAddress($smtp_opts['fromEmail'], $fromName);
$result = $mail->Send();
$mail->ClearAddresses();
$mail->ClearAttachments();
return $result;
}
$smtp_opts = array( ... ); // host, port, fromEmail, auth, username, password
send_email('mail@mail.com', 'Name', 'Subj', 'Msg', 'html', $smtp_opts);
$mail->AddAddress($smtp_opts['fromEmail'], $fromName);
If I am not mistaken, this command adds another recipient to the list of recipients. 如果我没记错的话,此命令会将另一个收件人添加到收件人列表中。 Try to remove it and send another test E-Mail.
尝试将其删除并发送另一封测试电子邮件。 You shouldn't be getting the copy-mail then.
那您不应该收到复制邮件。
我认为问题出在这行$ mail-> AddAddress($ smtp_opts ['fromEmail'],$ fromName);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.