XAMPP Configure the SMTP mail service so that the PHP mail () function can send mail _php tutorial

Source: Internet
Author: User

The PHP mail () message function is simple, but it also leads to the inability to use the currently popular SMTP server with authentication features (Gmail, 163, 126, etc.)
Now by configuring the XAMPP provided by the SendMail to make PHP mail () function can send mail normally, the following: Smtp.126.com as an example:
1. Locate the Xampp/php/php.ini file, locate the [mail function] statement block, and modify the following:
1 [Mail Function]
2 SMTP = smtp.126.com
3 Smtp_port = 25
4 Sendmail_from = xxx@126.com
5 Sendmail_path = "\" Your XAMPP installation directory \xampp\sendmail\sendmail.exe\ "-T"
2. Locate the Xampp/sendmail/sendmail.ini file and modify the following:
1 [SendMail]
2 Smtp_server = localhost
3 Smtp_port = 25
4 Default_domain = 126.com
5 Auth_username = your e-mail @126.com
6 Auth_password = Your password
7
8 Force_sender = xxx@126.com
3. Configure SSL service (optional)
Because Gmail, 163, 126 and so on need to use SSL to connect to the SMTP mail server, and XAMPP in the SendMail program does not support SSL connection.
If you are using a different mailbox and do not need SSL to connect to SMTP, then change the smtp.126.com to the corresponding SMTP server address.
We can download and install an SSL agent software, we use http://www.stunnel.org/here
After successful installation, open the Stunnel inside the stunnel.conf file, find the following code, modify the following:
Here we have added a [126-SMTP] node:
1; [GMAIL-SMTP]
2; client = yes
3; accept = 127.0.0.1:25
4; connect = smtp.gmail.com:465
5
6 [126-SMTP]
7 Client = yes
8 Accept = 127.0.0.1:25
9 Connect = smtp.126.com:465
4. Test your PHP mail () function, hehe!
View Source
Print? Www.2cto.com
01 $from _name = ' xxx ';
$from _email = ' xxx@126.com ';
$headers = ' From: $from _name < $from _email> ';
$body = ' This is a test mail ';
$subject = ' Test email ' from PHP mail () ';
$to = ' xxx@xxx.com ';
if (Mail ($to, $subject, $body, $headers)) {
The echo "success!";
Ten} else {
echo "Fail ...";
12}
?>
5. You've done it!

Author: JSON

http://www.bkjia.com/PHPjc/478161.html www.bkjia.com true http://www.bkjia.com/PHPjc/478161.html techarticle the PHP mail () message function is simple, but it also leads to the inability to use the currently popular SMTP server with authentication features (Gmail, 163, 126, etc.) now by configuring the XAMPP provided by Sendmai ...

  • Related Article

    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.

    Tags Index: