2013-02-22 55 views
1

我的主機使用SquirrelMail的SquirrelMail,我可以發送郵件,除此之外我也可以收到郵件。 拿着簡單的代碼來測試:php郵件不工作

$to  = '[email protected]'; 
$subject = 'the subject'; 
$message = 'hello'; 
$headers = 'From: [email protected]' . "\r\n" . 
    'Reply-To: [email protected]' . "\r\n" . 
    'X-Mailer: PHP/' . phpversion(); 

if(mail($to, $subject, $message, $headers)){ 
    echo '1'; 
}else echo '2'; 

phpinfo()函數

SMTP localhost 
smtp_port 25 
sendmail_from no value | no value 
sendmail_path /usr/sbin/sendmail -t -i -f **MAIL** | /usr/sbin/sendmail -t -i 

where **MAIL** is my personal mail, not the one, I want to send from 

但隨着我的劇本我不能發送電子郵件。接收2. wtf?

+1

您是否收到任何錯誤?它是否回顯「1」或「2」? – juco 2013-02-22 09:27:49

+0

當我嘗試發送它 - 接收2 – mozg 2013-02-22 09:28:34

+0

你在網絡服務器上運行它嗎? – 2013-02-22 09:28:37

回答

0

我發現我的管理員配置文件託管不是我想要發送的。 已關閉問題

0

我在做一個假設,$ to是您測試它時的有效地址。您的測試代碼沒問題,我只是在我的主機上運行它,並在我的Gmail帳戶中收到了一封電子郵件。

我的假設是,你的主機還沒有通過sendmail配置電子郵件。 SquirrelMail可能會使用SMTP,如果你有一個快速的Google,那麼你可以使用幾個SMTP類。

做一個快速的phpinfo()和尋找類似

sendmail_path /usr/bin/sendmail -t -i /usr/bin/sendmail -t -i 

這會告訴你,如果它至少對PHP的使用配置,如果它是存在的,還是不工作,你可以嘗試調用它直接來自命令行。如果仍然無法正常工作,則可能需要直接與主機聯​​系。

+0

sendmail_from - 無值,sendmail_path -/usr/sbin/sendmail -t -i -f MAIL |/usr/sbin/sendmail -t -i。但MAIL是我的個人信件,不是來自網站的郵件 – mozg 2013-02-22 09:47:02