The php sendmail function in IIS cannot send emails.

Source: Internet
Author: User

In the iis + php environment, we usually use the sendmail function to send emails, but the environment I configured cannot send emails using the sendmail function, and I found a solution for a long time, let me talk about it all the way.

First, you need to first go to the slave Node.

Open the php. ini file and find the following code:

The Code is as follows: Copy code

[Mail function]
; For Win32 only.
SMTP = localhost
Smtp_port = 25
; For Win32 only.
; Sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail-t-I ").
; Sendmail_path = ""
; Force the addition of the specified parameters to be passed as extra parameters
; To the sendmail binary. These parameters will always replace the value
; The 5th parameter to mail (), even in safe mode.
; Mail. force_extra_parameters =

By default, the local machine is used as the mail server. here we need to use sendmail to send mails. sendmail is used for configuration, such as sending via qq or 163 email addresses (generally in this way) therefore, we need to cancel all the options, that is, add ";" before SMTP = localhost and smtp_port = 25, and then delete sendmai_path = "" before, change sendmai_path = "d:/php/sendmail/sendmail.exe-t ".

The Code is as follows: Copy code

[Mail function]
; For Win32 only.
; SMTP = localhost
; Smtp_port = 25
; For Win32 only.
; Sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail-t-I ").
Sendmail_path = "d:/php/sendmail/sendmail.exe-t"
; Force the addition of the specified parameters to be passed as extra parameters
; To the sendmail binary. These parameters will always replace the value
; The 5th parameter to mail (), even in safe mode.
; Mail. force_extra_parameters =

Note that you only need to enable sendmail_path and save

Next, modify the sendmail. ini file in the sendmail Directory, which includes the following content:

The Code is as follows: Copy code

Smtp_server = smtp server address (for example, smtp.ym.163.com)
Auth_username = mailbox Login Name (such as info@xxxx.com)
Auth_password = Email Password (for example, xxxxxx)
Force_sender = sender address full write (such as info@xxxx.com)

There is another

The Code is as follows: Copy code

; Auto = use SSL for port 465, otherwise try to use TLS

Delete the previous ";", that is, enable the SSL secure logon option.

After the above four items are correctly entered and modified, save them and restart IIS for normal use. Now I'm happy to test my wordpress blog


Now start to debug the wordpress blog, but found that the server could not send the mail, sendmail has been installed, but continue to prompt that the mail failed to be sent. After a long analysis, I finally found the cause.

Step 1: Install the sendmail service
Download sendmail. RAR and store it in the sendmail directory under the php Directory. The structure is as follows:

Step 2: configure the php. ini file

The Code is as follows: Copy code
Sendmail_path = "D:/php/sendmail/sendmail.exe-t"

Check whether the File Location of the disc and position parameter sendmail.exe is determined.

Step 3: Configure sendemail. ini

The Code is as follows: Copy code

Smtp_server = smtp.sina.com.cn
Smtp_port = 25
The two are the accounts and passwords required for verification.
Auth_username = ifbs
Auth_password = XXXX

Step 4 grant the cmd.exe permission
C:/WINDOWS/system32/cmd.exe file with the read permission of users. If you do not grant permissions, the following error occurs.
Warning: mail () [function. mail]: cocould not execute mail delivery program

Step 5. Create a mail. php file and test the result

The Code is as follows: Copy code

<? Php
$ Mail = xxxx@sina.com.cn ";
$ Subject = "Mail Test ";
$ Text = "This is a test mail for function mail ()";

If (mail ($ mail, $ subject, $ text )){
Echo "email send success !";
} Else {
Echo "email send fail !";
}
?>

Access mail. php to test the result.

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.