PHP email sending problem: The email has been sent and Invalidaddress is returned:

Source: Internet
Author: User
Tags php email
PHP email sending problem: The email has been sent and Invalidaddress is returned: :
Why is this happening?


Reply to discussion (solution)

These are all custom prompts. the specific reason depends on the code. Trace the code...

Require_once APPLICATION_PATH. '/models/class. phpmailer. php ';
// Send an email
Class Send_Mail {

Function send_mail ($ fromname, $ subject, $ content, $ user_mail)
{
$ Mail = new PHPMailer (); // instantiate
$ Mail-> IsSMTP (); // enable SMTP
$ Mail-> Host = "smtp.163.com"; // Sina mail of the SMTP server
$ Mail-> Port = 25; // mail sending Port
$ Mail-> SMTPAuth = true; // enable SMTP Authentication
$ Mail-> CharSet = "UTF-8"; // character set
$ Mail-> Encoding = "base64"; // Encoding method
$ Mail-> Username = "yzhjtx@163.com"; // your mailbox
$ Mail-> Password = "hjtx123456"; // your Password
$ Mail-> Subject = $ subject; // mail title
$ Mail-> From = "yzhjtx@163.com"; // sender address (that is, your mailbox)
$ Mail-> FromName = $ fromname; // sender's name
$ Address = "$ user_mail"; // recipient email
$ Mail-> AddAddress ("$ address"); // add the recipient address, nickname
$ Mail-> IsHTML (true); // html content is supported
$ Emailtype = "HTML"; // mail type, text: text; webpage: HTML
$ Mail-> Body = $ content; // mail content
If (! $ Mail-> Send ()){
Return false;
} Else {
Return true; // sent successfully
}
}
}

These are all custom prompts. the specific reason depends on the code. Trace the code...


Email code:
Require_once APPLICATION_PATH. '/models/class. phpmailer. php ';
// Send an email
Class Send_Mail {

Function send_mail ($ fromname, $ subject, $ content, $ user_mail)
{
$ Mail = new PHPMailer (); // instantiate
$ Mail-> IsSMTP (); // enable SMTP
$ Mail-> Host = "smtp.163.com"; // Sina mail of the SMTP server
$ Mail-> Port = 25; // mail sending Port
$ Mail-> SMTPAuth = true; // enable SMTP Authentication
$ Mail-> CharSet = "UTF-8"; // character set
$ Mail-> Encoding = "base64"; // Encoding method
$ Mail-> Username = "yzhjtx@163.com"; // your mailbox
$ Mail-> Password = "hjtx123456"; // your Password
$ Mail-> Subject = $ subject; // mail title
$ Mail-> From = "yzhjtx@163.com"; // sender address (that is, your mailbox)
$ Mail-> FromName = $ fromname; // sender's name
$ Address = "$ user_mail"; // recipient email
$ Mail-> AddAddress ("$ address"); // add the recipient address, nickname
$ Mail-> IsHTML (true); // html content is supported
$ Emailtype = "HTML"; // mail type, text: text; webpage: HTML
$ Mail-> Body = $ content; // mail content
If (! $ Mail-> Send ()){
Return false;
} Else {
Return true; // sent successfully
}
}
}

Invalid address

Invalid address


But the email has been sent, and my mailbox has received a new email.

Check whether there is any Invalid address prompt in class. phpmailer. php. if not, search for the entire project.
By looking at this information, you can see why. Basic debugging method!

The email prompt is incorrect.

If you can receive the email but the email server returns this prompt, you need to check the status received by class. phpmailer. php.

Public function AddAddress ($ address, $ name = ''){
Return $ this-> AddAnAddress ('to', $ address, $ name );
}

Private function AddAnAddress ($ kind, $ address, $ name = ''){
If (! Preg_match ('/^ (to | cc | bcc | ReplyTo) $/', $ kind )){
Echo 'invalid recipient array: '. kind;
Return false;
}
$ Address = trim ($ address );
$ Name = trim (preg_replace ('/[\ r \ n] +/', '', $ name); // Strip breaks and trim
If (! Self: ValidateAddress ($ address )){
$ This-> SetError ($ this-> Lang ('invalid _ address'). ':'. $ address );
If ($ this-> conditions ){
Throw new phpmailerException ($ this-> Lang ('invalid _ address'). ':'. $ address );
}
Echo $ this-> Lang ('invalid _ address'). ':'. $ address;
Return false;
}
...

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.