我想从我的 PHP Web 应用程序发送电子邮件。我知道这是可能的,因为几个月前,我的系统上有这个“功能”,然后我开始使用 xampp 并且该功能消失了。
我想,当我回到本地服务器并使用本地 MySQL 数据库和像以前一样的东西时,我可以再次从我的网络应用程序发送电子邮件。
我将操作系统从 Mountain Lion 更新到 Mavericks(不知道这是否是主要问题),然后返回本地 apache 服务器,同时删除了 xampp。但我仍然无法从我的网络应用程序发送电子邮件。
我更改了正在使用的 php.ini 文件,以便可以使用邮件功能:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
; sendmail_from = [email protected] /cdn-cgi/l/email-protection
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "/usr/sbin/sendmail -t -i"
我在 maverick 上的默认 php.ini
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = [email protected] /cdn-cgi/l/email-protection
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On
; The path to a log file that will log all mail() calls. Log entries include
; the full path of the script, line number, To address and headers.
;mail.log =
; Log mail to syslog (Event Log on NT, not valid in Windows 95).
;mail.log = syslog
一个常见的问题是 ISP 阻止了端口 25,为了开发,我修改了 php.ini 邮件部分,如下所示,我的邮件服务器的 smtp 端口更改为端口 587 并更改了主机名。
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.example.net
; http://php.net/smtp-port
smtp_port = 587
sendmail_from = [email protected] /cdn-cgi/l/email-protection
auth_username = [email protected] /cdn-cgi/l/email-protection
auth_password = password
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = [email protected] /cdn-cgi/l/email-protection
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)