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. sm for sending emails in phpmailer.
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"