email-phpmailer發送郵件提示SMTP server error怎麼回事?

來源:互聯網
上載者:User
關鍵字 php email smtp phpmailer
phpemailsmtpphpmailer

以下是My Code
錯誤提示資訊為:
SMTP server error: Error: send HELO/EHLO first
如果把SMTPAuth改為true,錯誤為
SMTP Error: Could not authenticate. Mail errorSMTP Error: Could not authenticate.
請教大神是什麼原因?
是不是還需要哪些設定?還是phpmailer用得不對?
謝謝!

function sendmail($to,$subject,$msg)
{
require_once "PHPMailer/class.phpmailer.php";
include('PHPMailer/class.smtp.php');

$mail = new PHPMailer(); //建立執行個體$mail -> CharSet='utf-8'; //設定字元集$mail -> SetLanguage('en','include/PHPMailer/language/');  //設定語言類型和語言檔案所在目錄$mail -> IsSMTP(); //使用SMTP方式發送$mail -> SMTPAuth = false; //設定伺服器是否需要SMTP身分識別驗證$mail -> Host = "smtp.163.com"; //SMTP 主機地址$mail -> Port = 25; //SMTP 主機連接埠$mail -> From = "ajw211@163.com"; //寄件者EMAIL地址$mail -> FromName = 'ajw211'; //寄件者在SMTP主機中的使用者名稱$mail -> Username = "anthony"; //寄件者的姓名$mail -> Password = "**************"; //寄件者在SMTP主機中的密碼$mail -> Subject = $subject; //郵件主題$mail -> AltBody = 'text/html'; //設定在郵件內文不支援HTML時的備用顯示$mail -> Body = $msg;//郵件內容做成$mail -> IsHTML(true);  //是否是HTML郵件$mail -> AddAddress($to,'zy10601'); //收件者的地址和姓名$mail -> AddReplyTo($to,'zy10601'); //收件者回複時回複給的地址和姓名//$mail -> AddAttachment('include/id.csv','att.csv');//附件的路徑和附件名稱if(!$mail->Send()){    echo "Mail error" . $mail->ErrorInfo;}else{    echo "suucceed!!";}

}
$to = $_POST['toemail'];
$subject = $_POST['title'];
$msg = $_POST['content'];
sendmail($to,$subject,$msg);

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.