Example of using phpmailer to send emails in 163 mail

Source: Internet
Author: User
Tags php email word wrap
Phpmailer is a free php email sending plug-in. we can use phpmailer to log on to the specified email and then use this email to send an automatic email to us. now, the free email is like 163, all sina support, but sina... phpmailer is a free php email sending plug-in. we can use phpmailer to log on to the specified email and then use this email to send an automatic email to us. now, the free email is like 163, sina supports all of them, but sina needs to simply open the pop3 coroutine. if you have a good time, let's take a look at a phpmainer 163 email to send an email.

Note:If your server is installed with the anti-virus function for selling coffee and opening an account, we need to disable email protection. Otherwise, your email cannot be sent out to be blocked by this anti-virus service.

1. use the script sent by gmail,The code is as follows:

Include ("class. phpmailer. php "); include (" class. smtp. php "); // get the content of an external file $ mail = new PHPMailer (); $ body = file_get_contents('contents.html '); $ body = eregi_replace (" [] ",'', $ body); // Set the smtp parameter $ mail-> IsSMTP (); $ mail-> SMTPAuth = true; $ mail-> SMTPKeepAlive = true; $ mail-> SMTPSecure = "ssl"; $ mail-> Host = "smtp.gmail.com"; $ mail-> Port = 465; // enter your gmail account and password $ mail-> Username = "yourname@gmail.com"; $ mail -> Password = "password"; // Set the sender, it is best not to forge the address $ mail-> From = "yourname@gmail.com"; $ mail-> FromName = "Webmaster "; $ mail-> Subject = "This is the subject"; $ mail-> AltBody = $ body; $ mail-> WordWrap = 50; // set word wrap $ mail-> MsgHTML ($ body); // set the reply address $ mail-> AddReplyTo ("yourname@gmail.com", "Webmaster") (www.phprm.com ); // add an attachment. the attachment and the footer (www.phprm.com) are in the same directory. // otherwise, enter the complete path $ mail-> AddAttachment ("attachment.jpg "); $ Mail-> AddAttachment ("attachment.zip"); // Set the email address and name of the email recipient $ mail-> AddAddress ("toname@gmail.com", "FirstName LastName "); // Send an email in HTML format $ mail-> IsHTML (true); // Send an email using the Send method // process the email based on the sending result if (! $ Mail-> Send () {echo "Mailer Error:". $ mail-> ErrorInfo;} else {echo "Message has been sent ";}

2. use the 163 email sending script,You only need to change the SMTP configuration and account password. The SMTP configuration is as follows:

// Set smtp parameters // note that ssl protocol $ mail-> IsSMTP (); $ mail-> SMTPAuth = true; $ mail-> SMTPKeepAlive = true; $ mail-> Host = "smtp.163.com"; $ mail-> Port = 25;

If the test passes in the local wampserver environment, you must enable the php_openssl extension.

Experience Sharing:Some friends refer to this tutorial to use sina mail to log on and send emails. you find that sina Mail does not support this function, in fact, this is not because Sina Mail does not support this function. we need to open the pop3 protocol in Sina mail. the method for opening an account is to log on to Sina, we have a setting button next to more on the right side, after clicking enter, we will see that there is an "account setting", and there is a pop3 co-definition class at the bottom. we can open an account, so that you can try the above code to solve the problem, why do I not need to set 163 emails for a friend's department, because 163 emails enable pop3 by default.

Address:

Reprinted at will, but please attach the article address :-)

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.