0

我想从我的 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 = me@example.com

; 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"
4

1 回答 1

-1

在 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 = me@example.com

; 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 = user@example.net
auth_username = user@example.net
auth_password = password
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
于 2014-01-16T00:03:56.413 回答