从本地apache服务器发送邮件 [英] Send mail from a local apache server

查看:117
本文介绍了从本地apache服务器发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的PHP Web应用程序发送电子邮件.我知道这是有可能的,因为几个月前,我在系统上有了这个功能",然后我开始使用xampp,该功能消失了.

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.

我认为当我回到本地服务器并将使用本地MySQL数据库和以前的内容时,我可以再次从Web应用程序发送电子邮件.

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.

我将操作系统从Mountain Lion更新到Mavericks(不知道这是否可能是主要问题),然后返回本地apache服务器,同时删除了xampp.但是我仍然无法从我的Web应用程序发送电子邮件.

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.

我更改了正在使用的php.ini文件,因此可以使用邮件功能:

I changed the php.ini file that is in use so I can use the mail feature:

[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"

推荐答案

特立独行的默认php.ini

Mine default php.ini on maverick

[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,并更改了主机名.

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.

[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

这篇关于从本地apache服务器发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆