今天我正在寫這個大文本塊,因爲在遷移到優勝美地之後,PHP郵件功能在我的系統上不再工作了,我想解決這個問題並且幫助人們解決這個問題一次和所有!帶有OS X的PHP郵件功能sendmail
我記得,當我使用PHP的郵件功能數個月前,電子郵件來自哪裏的東西自動發送類似[email protected],但閱讀幾百頁的最後兩天後,我還沒有找到任何解決方案!
下面是我用來學習,我應該給什麼價值的MYHOSTNAME變量在配置文件後的第一個命令:
MBP-de-Ellon:~ Ellon$ echo $HOSTNAME
MBP-de-Ellon.local
這裏是我的文件需要進行配置的內容(基於教程):
的/ etc/hostconfig中
# This file is going away
AFPSERVER=-NO-
AUTHSERVER=-NO-
TIMESYNC=-NO-
QTSSERVER=-NO-
MYSQLCOM=-NO-
MAILSERVER=-YES-
/etc/postfix/main.cf中
# INTERNET HOST AND DOMAIN NAMES
#
# The myhostname parameter specifies the internet hostname of this
# mail system. The default is to use the fully-qualified domain name
# from gethostname(). $myhostname is used as a default value for many
# other configuration parameters.
#
#myhostname = host.domain.tld
#myhostname = virtual.domain.tld
myhostname = MBP-de-Ellon.local
# The mydomain parameter specifies the local internet domain name.
# The default is to use $myhostname minus the first component.
# $mydomain is used as a default value for many other configuration
# parameters.
#
#mydomain = domain.tld
# SENDING MAIL
#
# The myorigin parameter specifies the domain that locally-posted
# mail appears to come from. The default is to append $myhostname,
# which is fine for small sites. If you run a domain with multiple
# machines, you should (1) change this to $mydomain and (2) set up
# a domain-wide alias database that aliases each user to
# [email protected]
#
# For the sake of consistency between sender and recipient addresses,
# myorigin also specifies the default domain name that is appended
# to recipient addresses that have no @domain part.
#
#myorigin = $myhostname
#myorigin = $mydomain
/Applications/MAMP/bin/php/php5.6.10/conf/php.ini
[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25
; For Win32 only.
;sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; PERSONNAL NOTE : i've tried the three settings bellow
;sendmail_path = "env -i /usr/sbin/sendmail -t -i"
;sendmail_path = "/usr/sbin/sendmail -t -i"
sendmail_path = "sendmail -t -i"
mail.php(用於測試)
<?php
$from = 'MBP-de-Ellon.local';
if (mail('[email protected]', 'Subject', 'Message', 'From: ' . $from))
{
echo 'Send';
}
else
{
echo 'Not send';
}
?>
當我使用MA在我的瀏覽器中加載此頁時MP它打印「發送」但是......沒有通過郵箱... 當看與tail -f /var/log/mail.log
它打印Operation timed out
。
這讓我瘋狂,你對如何解決這個問題有什麼想法嗎? 請原諒我的語言錯誤。 在此先感謝您的答案。