Email-phpmailer sending mailtips SMTP server error What's going on?

Source: Internet
Author: User
Keywords PHP Email SMTP Phpmailer
Phpemailsmtpphpmailer

Here's My Code
The error message is:
SMTP Server Error:Error:send Helo/ehlo First
If you change the Smtpauth to True, the error is
SMTP error:could not authenticate. Mail ERRORSMTP error:could not authenticate.
What is the reason for asking the great God?
What settings are needed? Or is phpmailer used wrong?
Thank you!

function SendMail ($to, $subject, $msg)
{
Require_once "phpmailer/class.phpmailer.php";
Include (' phpmailer/class.smtp.php ');

  $mail = new Phpmailer ();//Create Instance $mail-charset= ' utf-8 ';//Set CharSet $mail-  > setlanguage (' en ', ' include/phpmailer/language/'); Set language type and language file directory $mail, ISSMTP (); Use SMTP to send $mail-Smtpauth = false; Set whether the server requires SMTP authentication $mail, Host = "smtp.163.com"; SMTP host address $mail Port = 25; SMTP host Port $mail, from = "ajw211@163.com"; Sender email Address $mail, fromname = ' ajw211 '; Sender's user name in the SMTP host $mail-Username = "Anthony"; Sender's name $mail, Password = "**************"; Sender in SMTP host password $mail-Subject = $subject; Message subject $mail-altbody = ' text/html ';  Set alternate display $mail, BODY = $msg when the message body does not support HTML;//message content made $mail-ishtml (true); is HTML mail $mail, addaddress ($to, ' zy10601 '); Recipient's address and name $mail, Addreplyto ($to, ' zy10601 '); The recipient replies with the address and name//$mail-addattachment (' include/id.csv ', ' att.csv ');//attachment path and attachment name if (! $mail->send ()) {echo " Mail error ". $mail->errorinfo;} else{echo "suucceed!!";}  

}
$to = $_post[' Toemail ');
$subject = $_post[' title '];
$msg = $_post[' content '];
SendMail ($to, $subject, $msg);

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.