Phpmailer Message Delivery Implementation code _php instance

Source: Internet
Author: User

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.

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.