我正在使用 MAC 操作系统并使用 mail() 将学生详细信息发送到我的邮箱。
它没有显示任何错误,但详细信息不会发送到邮件。
php.ini 中是否有 SMTP 设置?
对于 OSX Yosemite,这解决了我的问题:
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
SMTP=localhost
smtp_port=25
sendmail_path = "env -i /usr/sbin/sendmail -t -i"
确保您已配置
postfix
- 请查看此链接以了解更多信息:http://benjaminrojas.net/configuring-postfix-to-send-mail-from-mac-os-x-mountain-lion/
sudo nano -w /etc/hostconfig
MAILSERVER=-YES-
sudo cp /etc/postfix/main.cf /etc/postfix/main.cf.org
sudo nano -w /etc/postfix/main.cf
myhostname=my.known.host
# php.ini
sendmail_path = "sendmail -t -i"
来源:http://theandystratton.com/2009/fix-phps-mail-function-after-latest-os-x-leopard-update
您还可以使用 App Store 中的 OS X Server 应用程序。我相信它是免费的,至少对开发者来说是这样。如果您打开“邮件”选项,它会为您设置 postfix。您需要一个中继,或者您需要您的计算机有一个已建立的域;发送电子邮件很容易,但不被拒绝就很难了 :D