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

99封情书 提交于 2019-12-03 12:47:32

问题


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


回答1:


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');


来源:https://stackoverflow.com/questions/15402887/what-are-the-php-ini-parameters-to-set-for-sending-email

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!