PHP: mail() function with runtime ini_set() for SMTP and SMTP_PORT not working on Linux

拈花ヽ惹草 提交于 2019-12-04 13:07:27

If you're looking to your php.ini there is a short description that

ini_set('SMTP','myserver');
ini_set('smtp_port',25);

This both values are only for Windows. So if you want to send mails over SMTP on linux you have to install postfix for example and build a relay.

https://www.linode.com/docs/email/postfix/postfix-smtp-debian7

Or what is really much easier use a lib that can send SMTP mail over socket or curl like Swiftmailer.

http://swiftmailer.org/docs/sending.html

Thats much easier and its working.

I have had a look at this before and in PHP.ini there are two keys sendmail_from http://php.net/sendmail-from (For Win32) and sendmail_path http://php.net/sendmail-path (For Unix) on a wamp or similar setup for linux the default of this key is me@localhost which when on an actual mail server it should reject that email address as a user as they don't exist on the server.

Try adding something like...

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