Phpmail () Mail sending configuration method

Source: Internet
Author: User
Tags qmail
I wrote a method over the past two days to use phpmail (). I thought this method provided by php is very simple, convenient, and easy to use. it is actually not! The phpmail () function must be configured before sending an email. the following configuration method: If you are not using windows, then... I wrote a method over the past two days to use php mail (). I thought this method provided by php is very simple, convenient, and easy to use. it is actually not!

The php mail () function must be configured before sending an email. the configuration method is as follows:

If you are not using windows, the sendmail_path command is the only thing you need to worry about. if you are using Windows, you need to check the last two commands.

If you are using Linux or a Unix variant, sendmail_path should look like this:

Sendmail_path =/usr/sbin/sendmail

Or if you use Qmail:

Sendmail_path =/var/qmail/bin/sendmail

In this instruction in the PHP mail () function, you can also set the configuration parameters to specify the queue buffer options or display the set Return-Path header, as shown below:

Sendmail_path =/usr/sbin/

As a non-Windows user, this is all you have to do. if you are using Windows, you have more things to do. you also need to take a look at the values of SMTP and sendmail_from. do not confuse sendmail in the sendmail_from command name. although you have not used a program named Sendmail on Windows, it is only the command name. don't be scared by it.

In the result displayed in your phpinfo (), check the default values of SMTP and sendmail_from-they are either blank or contain random values. you should change them to meaningful values.

If you are determined to run an SMTP service program on this computer, your entries in the php. ini file should be as follows: SMTP = localhost

However, if you want to use the external mail server of your ISP (EarthLink in this example), the Mail in php. ini should look as follows: SMTP =

You can also use IP addresses instead of domain names, because computers do not distinguish these two entries.

The second configuration command is sendmail_from, which should be set to the email address in the From header. it can be modified in the script but is usually used as the default value. the following is a sample for this configuration directive referring to your own email address, the code is as follows:

Sendmail_from =

Send a simple email with the following code:

$txt = "First line of textnSecond line of text"; // Use wordwrap() if lines are longer than 70 characters $txt = wordwrap($txt,70); // Send email mail("","My subject",$txt);

At the beginning, I felt very good. NetEase mailbox, QQ mailbox, and GMAIL mailbox can all be received, but HOTMAIL, TOM, LIVE, and other mailboxes cannot receive such emails!

Identity authentication is generally required when a query email is sent, and the mail () provided by PHP is powerless and fragile!

Permanent link:

Reprint at will! Include 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: 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.