我使用下面的代碼來發送電子郵件到我的Gmail帳戶本地主機的工作:Sendmail配置(Fedora的)上使用PHP郵件功能
$to = 'My gmail address';
$subject = 'subject here';
$message = 'Test PHP email using mail()';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(!mail($to, $subject, $message, $headers)) echo "Error with sendmail mail()";
else echo 'Message has been sent';
運行腳本返回「消息已發送」但我從來沒有收到電子郵件(檢查垃圾郵件)。
我的操作系統是Fedora發行20(Heisenbug)和的phpinfo函數返回以下內容:
PHP Version: 5.5.23
System: Linux localhost.localdomain 3.18.9-100.fc20.x86_64
Configuration File: /etc/php.ini
Apache Version: Apache/2.4.10 (Fedora) PHP/5.5.23
Hostname:Port: localhost.localdomain:0
DOCUMENT_ROOT: /var/www/html
以下值同樣適用於本地&站長:
sendmail_from: no value
sendmail_path: /usr/sbin/sendmail -t -i
SMTP: localhost
smtp_port: 25
我兩者都已安裝sendmail & sendmail-cf。這些是sendmail.mc文件中的DAEMON_OPTIONS/LOCAL_DOMAIN設置:
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
LOCAL_DOMAIN(`localhost.localdomain')dnl
請幫忙。
[PHP郵件表單不能完成發送電子郵件]的可能重複(http://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-email) – 2015-04-04 12:36:43