phpmailer uses 163 mail to send emails example, phpmailer163_PHP tutorial

WBOY
Release: 2016-07-13 10:18:22
Original
1173 people have browsed it

Example of phpmailer using 163 email to send emails, phpmailer163

Note: If your server is installed with the maximum virus protection function for selling coffee and opening an account, we need to turn off an email protection, otherwise you The email cannot be sent because it is intercepted by this antivirus.

1. Script sent using gmail

Copy the code 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 smtp parameters
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
//Fill in 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 reply address
$mail->AddReplyTo(" yourname@gmail.com","Webmaster"(www.111cn.net));
//Add attachment, where the attachment and script are in the same directory
//Otherwise fill in the full 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 email using HTML format
$mail->IsHTML(true);
//Send email via Send method
//Process accordingly according to the sending result
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}

2. Script to send email using 163

You only need to change the SMTP configuration and account password. The SMTP configuration is as follows

Copy the code as follows
//Set smtp parameters
//Note that the ssl protocol is not required here
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true;
$mail->Host = "smtp.163.com";
$mail->Port = 25;

To pass the test in the local wampserver environment, you need to enable the php_openssl extension.

Experience Sharing

Some friends refer to this tutorial to use Sina mail to log in and send emails. When you find that Sina mail does not support this function, in fact, this is not that Sina mail does not support this function. We need to find the pop3 protocol in Sina mail. The way to open an account is to log in to Sina. We have a settings button next to More on the right. After we click to enter, we will see an "Account Settings". After entering, there is a pop3 syndicate class at the bottom. We can open an account with it. , so you can try the above code again and it will be solved. Some friends say why 163 mail does not need to be set, because 163 mail opens pop3 by default.
from:http://www.111cn.net/phper/php-cy/61846.htm

Using phpmailer on windows2003 to send 163 emails cannot be sent. Could not connect to SMTP host

You can telnet SMTP host 25 on Windows 2003 to see if the value is acceptable.
The SMTP of 163 should be smtp.163.com. It depends on the value you define.

telnet smtp.163.com 25

When phpmailer sends 163 emails, the Chinese characters are all garbled. Even if I change it to utl-8 or gbk, it won’t work. What’s the solution?

Pay attention to the encoding of the php file

Also set the encoding when sending
date_default_timezone_set("Asia/Shanghai");//Set the time zone Dongba District

$mail ->CharSet ="UTF-8";//Set the email encoding, the default is ISO-8859-1, if you send Chinese, this must be set

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/884178.htmlTechArticleExample of phpmailer using 163 email to send emails, phpmailer163 Note: If your server is installed to sell coffee and open an account for maximum virus protection Function: We need to turn off an email protection...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template