Cases of successful PHP test email sending, and cases of php mail sending. PHP tests successful mail sending cases. The mail () function of php mail sending case is used to connect to the mail server and use the smtp protocol to interact with the server and send emails. Note: 1. successful PHP mail sending cases and php mail sending cases
Functions of mail:Connect to the mail server and use the smtp protocol to interact with the server and send emails.
Note:
1. the mail function does not support esmtp. --- that is, it can only be directly cast and cannot be logged on.
2. from the above, we can only direct to the final receiving server address. the address is in PHP again. ini specified, so we want to use the mail () function to send mail to the aseoev@163.com, we want ---
1) query the address of the 163 mail server
2) write the address to php. ini.
The php instance code is as follows:
SMTP = 163mx02.mxmail.netease.com sendmail_from = wusong@192.168.1.100 var_dump(mail('12345678@qq.com','from php mail function','very intresting'));
However, to use the mail function provided by php to send emailsLinuxInstallSendmail component.
If you do not have this sendmail component, we can usePhpmailer functionThe 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 ()? 'Sending successfully': 'Sending failed';?>
The code is as follows:
<? Php/** use the PHPMailer class for sending steps: 0: Introduction 1: Instantiation 2: configuration attribute 3: Call to send **/require ('. /PHPMailer/class. phpmailer. php '); $ phpmailer = new PHPMailer ();/* you can use the mail () function under win to set phpmailer to sendmail in linux, the qmail component can use the smtp protocol to log on to an account and send */$ phpmailer-> IsSMTP (); // use the smtp protocol to send $ phpmailer-> Host = 'smtp .163.com '; $ phpmailer-> SMTPAuth = true; $ phpmailer-> Username = ''; // account used to send emails (account used to send emails in 163 email) $ phpmailer-> Password = ''; // Send the email password // you can send the $ phpmailer-> CharSet = 'utf-8'; $ phpmailer-> From = 'never _ 4ill@163.com '; $ phpmailer-> FromName = 'neverkill '; $ phpmailer-> Subject = 'superstart Aseoe'; $ phpmailer-> Body = 'helping House (http://www.bkjia.com focuses on front-end development and programming design. '; // Set the recipient $ phpmailer-> AddAddress ('never _ 4ill@163.com', 'neverkill '); // add a CC $ phpmailer-> AddCC ('20140901 ', 'aseoe'); // send the echo $ phpmailer-> send ()? 'OK': 'fail ';
Add a method to use the preceding example:
Directly decompress the phpmailer package and put it in the root directory to run. directly put the file in the local wamp root directory and run the 02.php email to send it (the php file can be executed) -(if not, create a folder in the root directory and repeat it once) http: // localhost/02.php.
The above is a successful case of php mail sending, and I hope it will help you learn it.
The role of the secure mail () function is to connect to the mail server and use the smtp protocol to interact with the server and send emails. Note: 1 ,...