Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the php.ini parameters to set for sending email? [duplicate]

Tags:

php

wamp

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

like image 217
pheromix Avatar asked Mar 14 '13 06:03

pheromix


1 Answers

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 = [email protected]

; 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', '[email protected]');
like image 50
Jhonathan H. Avatar answered Oct 04 '22 20:10

Jhonathan H.