In this tutorial, phpmailer sends emails.

Source: Internet
Author: User
Tags php server
I used WampServer & nbsp; Version & nbsp; 2.1 on the local machine to test whether phpmailer sends emails. I downloaded the latest class. phpmailer. php and class. smtp. php files, and created a php file phpmail. php to test the Mail sending function. the code is as follows: & lt ;? Phpmailer for php & nb
I use WampServer Version 2.1 on the local machine as the php server to test phpmailer to send emails. I downloaded the latest class. phpmailer. php and class. smtp. php files, and created a php file phpmail. php to test the Mail sending function. the code is as follows:
Require_once ('class. phpmailer. php ');
Include ("class. smtp. php ");

$ Mail = new PHPMailer (); // Create a mail sending class
$ Address = $ _ POST ['address'];
$ Mail-> SMTPDebug = true;
$ Mail-> IsSMTP (); // send using SMTP
$ Mail-> CharSet = "UTF-8"; // chinese;
$ Mail-> Host = "smtp.163.com"; // Local smtp server
$ Mail-> SMTPAuth = true; // enable SMTP verification
$ Mail-> Username = "cnmhg168"; // user name (enter the complete email address)
$ Mail-> Password = "******"; // Password

$ Mail-> From = "cnmhg168@163.com"; // email address of the sender
$ Mail-> FromName = "";
$ Mail-> AddAddress ("mysimpledesign@163.com", "tttt"); // recipient address

// $ Mail-> AddAttachment ("/var/tmp/file.tar.gz"); // add an attachment
$ Mail-> IsHTML (true); // set email format to HTML // whether HTML format is used

$ Mail-> Subject = "PHPMailer test mail"; // mail title
$ Mail-> Body = "Hello, this is the test email, Baidu"; // the email content
$ Mail-> AltBody = "from Mars"; // additional information, which can be omitted
// $ Mail-> SMTPDebug;

If (! $ Mail-> Send ())
{
Echo "failed to send the email.

";
Echo "error cause:". $ mail-> ErrorInfo;
Exit;
}

Echo "email sent successfully ";


?>
There is no problem with the user name and password, but the following error message is displayed. I don't know where the problem is. can you solve it?


(! ) Notice: Undefined index: address in D: \ wamp \ www \ PHPMailer \ phpmail. php on line 6
Call Stack
# Time Memory Function Location
1 0.0041 373128 {main} () .. \ phpmail. php: 0
SMTP-> get_lines (): $ data was ""
SMTP-> get_lines (): $ str is "220 163.com Anti-spam GT for Coremail System (163com [20121016])"
SMTP-> get_lines (): $ data is "220 163.com Anti-spam GT for Coremail System (163com [20121016])"
SMTP-> from server: 220 163.com Anti-spam GT for Coremail System (163com [20121016])
SMTP-> get_lines (): $ data was ""
SMTP-> get_lines (): $ str is "250-mail"
SMTP-> get_lines (): $ data is "250-mail"
SMTP-> get_lines (): $ data was "250-mail"
SMTP-> get_lines (): $ str is "250-PIPELINING"
SMTP-& gt; get_lines (): $ data is "250-mail 250-PIPELINING"
SMTP-& gt; get_lines (): $ data was "250-mail 250-PIPELINING"
SMTP-> get_lines (): $ str is "250-AUTH login plain"
SMTP-& gt; get_lines (): $ data is "250-mail 250-PIPELINING 250-AUTH login plain"
SMTP-& gt; get_lines (): $ data was "250-mail 250-PIPELINING 250-AUTH login plain"
SMTP-> get_lines (): $ str is "250-AUTH = login plain"
SMTP-> get_lines (): $ data is "250-mail 250-PIPELINING 250-AUTH login plain 250-AUTH = login plain"

Related Article

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.