8

I want to send email from my PHP code, but I received warning messages. So what are the php.ini parameters to set ?

Sverri M. Olsen
  • 13,055
  • 3
  • 36
  • 52
pheromix
  • 18,213
  • 29
  • 88
  • 158

1 Answers1

13

To check/change your PHP mail configuration:

Open your php.ini file (if you don't know where this is, see below) Search for the line that reads [mail function] 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 php.ini file Restart your web server

An example of what the mail settings could look like when you first open the php.ini file:

[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 =

Additional info is in echoing phpinfo() you can 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 php.ini and sendmail_path to see the values you need to use.

Another idea is you might use ini_set() to properly config your mail setting like this

Add the following code to the top of your email script if your mail script continues to fail.

// Please specify your Mail Server - Example: mail.example.com.
ini_set("SMTP","mail.example.com");

// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
ini_set("smtp_port","25");

// Please specify the return address to use
ini_set('sendmail_from', 'example@YourDomain.com');
Jhonathan H.
  • 2,734
  • 1
  • 19
  • 28
  • 1
    Well actually this issue is that WINDOWS does not come with a mail server. You have to install one to make send() work as well as change some config parameters. – RiggsFolly Apr 29 '13 at 22:35