php 从本地 apache 服务器发送邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21149535/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Send mail from a local apache server
提问by kalafun
I want to send emails from my PHP web app. I know that it is possible because a couple of months ago, I had this "feature" on my system, then I started to use xampp and the feature disappeared.
我想从我的 PHP Web 应用程序发送电子邮件。我知道这是可能的,因为几个月前,我的系统上有这个“功能”,然后我开始使用 xampp 并且该功能消失了。
I thought that when I come back to my local server and will use a local MySQL database and stuff like I used to before, I could send emails from my web apps again.
我想,当我回到我的本地服务器并像以前一样使用本地 MySQL 数据库和其他东西时,我可以再次从我的网络应用程序发送电子邮件。
I updated my operating system from Mountain Lion to Mavericks (no idea whether this could be the main issue) and went back to local apache server also removing xampp. But I still can't send emails from my web app.
我将操作系统从 Mountain Lion 更新到 Mavericks(不知道这是否可能是主要问题)并返回到本地 apache 服务器,同时删除了 xampp。但我仍然无法从我的网络应用程序发送电子邮件。
I changed the php.ini file that is in use so I can use the mail feature:
我更改了正在使用的 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]
; 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"
回答by Joris Ros
Mine default php.ini on 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]
; 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
A common problem is that a ISP has blocked port 25, for development i have modified the php.ini section mail as below, the smtp port of my mail server changed to port 587 and changed the hostname.
一个常见的问题是 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]
auth_username = [email protected]
auth_password = password
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = [email protected]

