當我通過PHPmailer(SMTP)發送測試郵件時,我的電子郵件附加到收件人列表。以下是接受者看到的收件箱中的電子郵件PHPmailer發送複製到我的電子郵件
的第二封郵件是我的。我怎樣才能阻止呢?
這裏是我的代碼
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('[email protected]', 'Name', 'Subj', 'Msg', 'html', $smtp_opts);
哦,我的上帝!我從早上開始尋找這個錯誤...神聖sh_t!:( – 2012-08-04 11:56:16
謝謝!我很慚愧... – 2012-08-04 11:58:45
@NikitaGavrilov不要冒汗,我知道你有什麼感覺,有時只需要一眼就能發現問題,程序員花了數小時的時間尋找,儘管如果你接受了其中一個答案會很好:)謝謝。 – ATaylor 2012-08-04 12:06:26