PHP Test Successful email case, PHP mail send case
The Mail () function works by connecting to the mail server, using the SMTP protocol, interacting with the server, and casting messages.
Attention:
1, the Mail function does not support the ESMTP protocol,---namely, can only direct, cannot login
2, from the previous article, we can only direct to the final receiving server address. And that address is specified in php.ini, so we want to use the mail () function to send to aseoev@163.com, we want to---
1) Query the address of the 163 mail server
2) write the address in the php.ini.
The PHP instance code is as follows:
But using PHP's own mail function to send mail we need to install a sendmail component in Linux to be unusable otherwise.
If you do not have this sendmail component we can use the Phpmailer function to manipulate, the example code is as follows:
<?php require ('./phpmailer/class.phpmailer.php '); $phpmailer = new Phpmailer (); $phpmailer->issmtp (); $phpmailer->host = ' smtp.163.com '; $phpmailer->smtpauth = true; $phpmailer->username = "; $phpmailer->password = "; $phpmailer->charset = ' utf-8 '; $phpmailer->from = "; $phpmailer->fromname = "; $phpmailer->subject = "; $phpmailer->body = "; $phpmailer->addaddress (' never_kiss@163.com ', ' Aseoe '); echo $phpmailer->send ()? ' Send succeeded ': ' Send failed ';
With no content on it, look at a band with content, the code is as follows:
<?php /** Use the Phpmailer class to send the message step: 0: Introduction 1: Instantiation 2: Configuration attribute 3: Call sent **/require ('./phpmailer/class.phpmailer.php '); $phpmaile R = new Phpmailer ();
Add a method that uses the above example:
Phpmailer compressed package directly to the root directory can be run, directly put the file to the local Wamp root directory, run 02.php Mail can be issued (the premise PHP file executable)-(no words in the root directory to build a folder repeat operation once) http://localhost/02.php.
The above is a successful case of sending mail to PHP, I hope that everyone's learning is helpful.
http://www.bkjia.com/PHPjc/1065150.html www.bkjia.com true http://www.bkjia.com/PHPjc/1065150.html techarticle PHP test successful mail sending case, PHP mail send case mail () function: Connect to the mail server, use the SMTP protocol, interact with the server and cast the message. Note: 1 、...