php.ini file is where you configure your PHP installation. This is the file you need to edit in order to configure PHP to send mail.
You need to ensure that the
php.ini file contains details of the mail server that should be used whenever your application sends mail.
To check/change your PHP mail configuration:
- Open your
php.inifile (if you don’t know where this is, see below)
- Search for the line that reads
- Add/change the details of your mail server. This could be a local mail server or the mail server of your ISP.
- Save/close the
- Restart your web server
Here’s an example of what the mail settings could look like when you first open the
; For Win32 only.
SMTP = localhost
smtp_port = 25; For Win32 only.
;sendmail_from = email@example.com
; For Unix only. You may supply arguments as well (default: “sendmail -t -i”).
If you’re using a UNIX based system, you will need to change the line that reads
;sendmail_path =. You will also need to remove the semicolon from the start of this line (semicolons indicate that the line is a comment). For example,
sendmail_path = /usr/sbin/sendmail.
If you’re using a Windows system, you should change the line that reads
SMTP = localhost to include your mail server (or your ISP’s mail server). You could leave it at
localhost if you’re using your own local SMTP server. If you aren’t using your own local SMTP server, you will need to enter a mail server that you have access to (such as your ISP’s mail server). For example,
SMTP = mail.earthlink.net.
You should also set a default “From” email address by changing the line that reads
;sendmail_from = firstname.lastname@example.org. For example,
sendmail_from = email@example.com.
Don’t Know Your
php.ini Location or
If you don’t know where your
php.ini is, or what your
sendmail_path setting should be, read on…
php.ini may be located here:
/private/etc/php.ini. And there’s a chance that your sendmail path will be at
/usr/sbin/sendmail). Having said this, each PHP installation is different, so you should check using
Fortunately, this is easy to do.
phpinfo() is used to view your PHP configuration details. You can do this by creating a .php file with the following line on it:
<?php phpinfo(); ?>. When you run this in your browser, you will see a full list of PHP configuration variables. Simply search for the lines that contain
sendmail_path to see the values you need to use.