Get the App
SLTechnology News&Howtos  ›  Development  › 

The solution of email sending failure in php

Shulou Source: shulou.com Published: 2022-06-03 11:35:56 09月19日 Update

This article is to share with you about the solution to the failure of email delivery in php. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The solution to the failure of php email sending: 1, configure the appropriate SMTP server address and port information in php.ini; 2, send mail with the help of sendmail program.

This article operating environment: linux5.9.8 system, PHP7.1 version, Dell G3 computer

What if I fail to send php email?

PHP send email error

Warning: mail () [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set () in

Solution:

The Mail function of PHP uses the E-Mail issued by the SMTP service. In other words, you need to configure the appropriate SMTP server address and port information in php.ini. If you need to issue E-Mail on your local computer, that is

SMTP = localhostsmtp_port = 25

In that case, you need to configure the SMTP service on your own local machine. You can try to open IIS's SMTP service.

To be clear, the mail () function in php uses the sendmail program to send mail, and sendmail-t-I is generally the linux/unix system's own program, but the windows system does not have this program, so you can not directly use the mail () function to send mail.

Realize sending email by using mail () under windows

1. The sending mail system must have SMTP service. Install the SMTP Service component under "windows Server 2003":

A, "add and remove Windows components"-> "Application Server"-> "Internet Information Services (IIS)" click "details".

B. Select "SMTP Service" to install.

2. Set SMTP:

A. Open the Internet Information Services (IIS) Manager and find the default SMTP virtual server.

Right-click on the service and select Properties.

C. Click the "access" table item in the pop-up "default SMTP Virtual Server Properties" box, and select the "Authentication" button.

D. in the pop-up "Authentication" box, select only "Anonymous access" and nothing else.

E, go back to the "access" table item, select the "Relay" button, click the "add" button in the pop-up "Relay restriction" box, and add the IP address of 127.0.0.1.

3. Modify "php.ini":

-

[mail function]; For Win32 only.SMTP = localhostsmtp_port = 25; For Win32 only.sendmail_from = me@example.com

-

4. Run this program and log in to the mailbox shown in "$toaddress" to view the email.

$toaddress = 'xuzhang@mascatv.com';$subjects =' test the php mail';$mailcontent = 'Onlu test the php mailbox' from address = 'From: me@localhost.com';mail ($toaddress,$subjects,$mailcontent,$fromaddress); thank you for reading! This is the end of this article on "the solution to the failure of sending email in php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Services mail programs information servers selections systems methods functions addresses buttons configuration appropriate content properties more ports articles components identity Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Redmi Xiaomi MySQL NVidia