1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Discuss in my forum

How to Configure PHP to Use a Remote SMTP Server for Sending Mail


Man using laptop on sofa
Sam Edwards/Caiaimage/Getty Images
PHP makes it easy to send mail from Web applications. But it still needs a bit of configuration. As you probably know, PHP configuration happens php.ini.

The relevant section for email configuration is [mail function], and to make PHP use an external mail server you must set SMTP to your ISP's mail server's address. This will be the same address that you use in your email program for the outgoing mail server, "smtp.isp.net", for example. The other setting sendmial_from, which specifies the default email address PHP emails are sent from.

Configure PHP to Use a Remote SMTP Server for Sending Mail

Note that setting up the internal mail function to use SMTP is only available on Windows. On other platforms, PHP should use the locally available sendmail or sendmail drop-in just fine. Alternatively, you can use the PEAR Mail Package.

A typical configuration might look like:

[mail function]
SMTP = smtp.isp.net
sendmail_from = me@isp.net

©2014 About.com. All rights reserved.