There's a problem with Phpmailer e-mail

Source: Internet
Author: User
Require_once (' class.phpmailer.php '); The downloaded file must be placed in the directory where the file is located
$address =$_post[' address ';
echo $address. "
";
$mail = new Phpmailer (); Set up a mail sending class
$address = $_post[' address '];
$mail->issmtp (); Send using SMTP mode
$mail->host = "smtp.163.com"; Your enterprise Post office domain name
$mail->smtpauth = true; Enable the SMTP authentication feature
$mail->username = "*********@163.com"; Post Office User name (please fill in the full email address)
$mail->password = "********"; Post Office password
$mail->from = "******@163.com"; Email Sender Email Address
$mail->fromname = "";
$mail->addaddress ("$address", "QQ"), or/or the recipient's address, can be replaced by any email message you want to receive,
$mail->subject = "phpmailer test mail"; Message header
$mail->body = "Hello, this is Test mail"; Message content
$mail->altbody = "The body in plain text for non-html mail clients"; Additional information, you can omit

if (! $mail->send ())
{
echo "message failed to send.

";
echo "Error Reason:". $mail->errorinfo;
Exit
}

echo "Mail sent successfully";
?>

Warning:preg_match () [Function.preg-match]: compilation failed:reference to non-existent Subpattern @ offset 626 in C: \ Program Files\apache software foundation\apache2.2\htdocs\class.phpmailer.php on line 667
Message delivery failed.
Error reason: Must provide at least one recipient email address.



Reply to discussion (solution)

$mail->addaddress ($address, "QQ"); So what?

$mail->addaddress ($address, "QQ"); So what?
No, you tried, okay?

Echo $address; What is the value

Output your $address Look, may not be the correct email address

Output your $address Look, may not be the correct email address
I already have the output, and after I change it, there's a new problem.
Could not instantiate mail function. Message delivery failed.
Error reason: Could not instantiate mail function

Echo $address; What is the value
That is to see if my mailbox has errors, the result of the output is my mailbox

$mail->smtpdebug = 1; Plus this sentence to see if we can find the reason

$mail->smtpdebug = 1; Plus this sentence to see if we can find the reason
No, the result is could not instantiate mail function. Message delivery failed.
Error reason: Could not instantiate mail function.

Whether your 163 account is a valid account. Try QQ mailbox can send?
$mail->addaddress ($address); Try this.

Whether your 163 account is a valid account. Try QQ mailbox can send?
$mail->addaddress ($address); Try this.
No, I think it's not a coding problem, it's a php.ini configuration problem.

Whether your 163 account is a valid account. Try QQ mailbox can send?
$mail->addaddress ($address); Try this.
I found a few words on some websites, but I couldn't open the details.

Email error:could not instantiate mail function this is actually caused by our improper settings, background email settings require us to this kind of: name if not set ...

I also encountered the same problem, in the win environment debugging is completely normal, transplanted to centos5.9 this is the case
Invalid address:12336@qq.com message sent failed, error message: You must provide at least one recipient email address.

  • 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.