0
在Godaddy服務器上的PHPMailer上,當我使用SMTPAuth = false
時,腳本可以發送郵件而沒有任何問題。但是,如果將值設置爲SMTPAuth = true
,則無法連接到SMTP併發出錯誤。從網絡郵件打開時,電子郵件和密碼正在工作。當使用SMTPAuth = true時,PHPMailer SMTP_Connect()失敗
我用下面的代碼使用的PHPMailer發送郵件:
$fromEmail = ['message'=>'[email protected]','confirm'=>'[email protected]'];
if(isset($fromEmail[$purpose])) {
$fromEmail = $fromEmail[$purpose];
}
else{
$fromEmail = $fromEmail['message'];
}
$mail = new \PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->IsHTML(true);
$mail->Host = 'a2plcpnl0721.prod.iad2.secureserver.net';
//$mail->Port = 465;
$mail->SMTPAuth = false; //true
//$mail->SMTPSecure = 'ssl';
$mail->Username = $fromEmail;
$mail->Password = "1seerain";
$mail->setFrom($fromEmail, 'InspireTrend');
$mail->addReplyTo($fromEmail, 'InspireTrend');
$mail->Subject = $subject;
$mail->Body = $msg;
if($multiEmail && is_array($email)){
foreach ($email as $key => $value) {
$mail->clearAddresses();
$mail->AddAddress($value);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
}
else{
$mail->AddAddress($email);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
是有我丟失任何配置。任何建議都是可觀的。