
我正在嘗試使用 smtp 透過 phpmailer 發送郵件。
我的錯誤:
SMTP -> ERROR: RCPT not accepted from server: 554 5.7.1 : Client host rejected: Access denied
SMTP Error: The following recipients failed: xxxxxxxxx.com Mailer Error: SMTP Error: The following recipients failed: xxxxxxxxxxxx.com
SMTP server error: 5.7.1 : Client host rejected: Access denied
這是代碼:
$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 = "xxxxxxxxxxxxx";
$mail->Port = "587"; // or 587
$mail->IsHTML(true);
$mail->Username = "xxxxxxxxx";
$mail->Password = "xxxxxxxxxx";
$mail->SetFrom("[email protected]");
$mail->Subject = "Price Change Notification";
$mail->Body = "Test E-mail";
$mail->AddAddress("[email protected]");
if(!$mail->Send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}
else{
echo "Message has been sent";
}
答案1
如果不知道您正在運行哪個郵件伺服器,則很難具體確定,但許多人鎖定他們的郵件伺服器,只允許您從已批准的 IP 位址發送郵件。這裡的情況似乎就是這樣。您需要與管理您的郵件伺服器的人員聯繫,並讓他們允許 Web 伺服器發送郵件。
答案2
嘗試尋找您是否不在黑名單中:
答案3
以防萬一有人深入研究上述問題,請確保您的用戶名與SetFrom
地址相同。某些郵件伺服器配置不允許使用不同的寄件者位址。另一種選擇是簡單地將郵件別名新增至實際郵件帳戶。