【发布时间】:2015-05-24 08:04:09
【问题描述】:
我一直在研究这个主题,因为我在使用我的 php 脚本发送电子邮件时遇到了一些困难。当我执行我的contactform.php 时,它会执行send_form_email.php,这基本上表示电子邮件已发送。我的脚本没有任何问题,因为我有一个朋友在他的服务器上对其进行代码测试,他能够提交表单并生成电子邮件。
所以现在我完成了配置 sendmail.ini 和 php.ini 的步骤,我相信我根据在线教程正确配置了它。我还在互联网上的 aws 服务器上对此进行了测试,该服务器已禁用防火墙,因此所有端口均已打开,但仍无法通过我的 php 脚本发送电子邮件。我将发布我用来配置 .ini 文件的示例。
所以现在我要创建一个邮件服务器了。不太确定我的选择是什么。我正在考虑一个中继邮件服务器,它可以承担工作负载,我不需要经历部署邮件服务器的麻烦。然后我在 xampp 上有 Mercury 进行配置,但找不到可以帮助我的像样的教程。所以我在这里寻求专业建议我应该如何解决这个问题。在我的 gmail 中,我启用了所有功能,因此使用 pop3、imap 和 smtp 的所有流量都可以发送和接收,只是不太确定我能做什么。我从未部署过电子邮件服务器,所以我正在寻找非常易于使用的东西。这是一个小项目,我最终会放弃。
https://shellcreeper.com/enable-send-email-in-xampp/
php.ini from:
[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 = postmaster@localhost
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path = "\"\XAMPP\sendmail\sendmail.exe\" -t"
To:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = {your gmail username}@gmail.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"\XAMPP\sendmail\sendmail.exe\" -t"
Sendmail.ini
from:
smtp_server=localhost
smtp_port=25
to:
;smtp_server=localhost
;smtp_port=25
and add this in the bottom of your sendmail,ini:
;new config:
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=tls
error_logfile=error.log
pop3_server=
pop3_username=
pop3_password=
force_recipient=
hostname=
auth_username={your gmail username}@gmail.com
auth_password={your gmail password}
force_sender={your gmail username}@gmail.com
【问题讨论】: