Native environment: LAMP (ubuntu12.10);
The SMTP server is using Stmp.163.com. In the beginning for this or egg pain, the first use of stmp.qq.com results sent by Tencent as a spam mail processing is not sent out,
There's no such things. Then I changed to stmp.gmail.com, and then opened the Google Mailbox Pop service, but always can not verify success. Finally, register a 163, run the code is successful.
No pain, no pressure ~ ~
The code is as follows:
Copy Code code as follows:
<?php
Require ("phpmailer/class.phpmailer.php");
Require ("phpmailer/class.smtp.php");
$mail =new Phpmailer ();
Set up Phpmailer use SMTP server to send email
$mail->issmtp ();
Sets the character encoding for the message, if unspecified, the ' UTF-8 '
$mail->charset= ' UTF-8 ';
Add a recipient address that can be used multiple times to add multiple recipients
$mail->addaddress (' ********* @qq. com ');
Set the message body
$message = ' <B> This is a test email </B> ';
$mail->body= $message;
Sets the From field of the message header.
For NetEase's SMTP service, this part must be the same as your actual account number, or it will verify an error.
$mail->from= ' ****@163.com ';
Set Sender Name
$mail->fromname= ' yourname ';
Set Message headers
$mail->subject= ' mail test ';
Set up an SMTP server. NetEase's SMTP server is used here.
$mail->host= ' smtp.163.com ';
Set to require verification
$mail->smtpauth=true;
Set user name and password, that is, NetEase Mail username and password.
$mail->username= ' * * * * *;
$mail->password= ' * * * * *;
Send the message.
$mail->send ();
?>
The second line and the third line contains the PHP mail packet, the other online blog to write the download address is this http://phpmailer.sourceforge.net/, but I did not open, or write it here.
I was in Baidu in the next. Baidu can still be found.
PHP has a mail () function to send the mail, but to install a sendmail, I installed but did not send out, I do not know what is the configuration of the problem or what reason, in short this finally or in this simple way to achieve.