我在PHPMailer中遇到過一些奇怪的行爲。我正在使用我的Gmail帳戶進行SMTP設置。但每次PHP發送一封電子郵件(在這種情況下,這是爲了重置密碼),我也收到相同的電子郵件。除了當我的Gmail帳戶要求重設密碼時。PHPMailer與Gmail smtp結合發送郵件兩次
這是代碼;
//set email settings
$mail = new PHPMailer;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'ssl://smtp.gmail.com'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Port = 465;
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'mypassword'; // SMTP password
$mail->From = '[email protected]';
$mail->FromName = 'Bla';
$mail->AddAddress($email); // Name is optional
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'Bla registration';
$mail->Body ="
<html>
<header><title>Welcome to Bla</title></header>
<body>
<p>Hello,</p>
<p>Welcome to Bla. Thank you for registering an account. Before you can start inventing music, please activate your account</p>
<p><a href='http://www.bla.com/register/activate.php?activation=$activationcode&email=$email'> http://www.Bla.com/register/activate.php?activation=$activationcode&email=$email</a></p>
See you soon on Bla!
</body>
</html>";
$mail->Send();
沒有錯誤或類似的東西。電子郵件實際上是發送和接收的。唯一的問題是我也收到,因爲用戶名中的電子郵件地址是我的電子郵件地址。有誰知道爲什麼發生這種情況?