2012-04-24 50 views
1

正如標題中提到,我可以telnet到我的web服務器的25端口將郵件發送到遠程服務器在PHP

但問題是,在這裏這個簡單的代碼不發送電子郵件了。輸出表明它已發送出去,但沒有收到電子郵件。

$to = "[email protected]"; 
$subject = "test"; 
$msg = "Ite!"; 
$headers = "From: [email protected]\r\nReply-To: [email protected]"; 
mail("$to", "$subject", "$msg", "$headers"); 
echo "finished!"; 
echo "Your mail was sent."; 

正如下面顯示了我的php.ini文件配置

[mail function] 
; For Win32 only. 
; http://php.net/smtp 
SMTP = smtp.realtest.com 
; http://php.net/smtp-port 
smtp_port = 25 

; For Win32 only. 
; http://php.net/sendmail-from 
sendmail_from = [email protected] 

我在這個可怕的情況是stucked兩個星期,按照前文的話題,一直沒有幫助和報價,我真的需要這個來做起來。感謝你們。對不起,我經驗不足。

另一方面,我意識到如果沒有認證需要,如何從電子郵件地址發送電子郵件?請回答我的說明,非常感謝。

+2

你*是*運行的Win32,對不對? – 2012-04-24 04:01:17

+0

託管服務器?共享主機? VPS? – 2012-04-24 04:07:18

+0

你怎麼知道它被髮送? 'mail'是否返回true? – Alex 2012-04-24 04:15:41

回答

0

你可以嘗試這些鏈接 http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.htmlhttp://php.net/manual/en/ref.mail.php(你會發現也可以使用sendmail的窗口;))

也爲sendmail_from指定的E-mail地址必須存在SMTP服務器上,並確保您運行腳本的計算機的IP由SMTP服務器信任,因此它不會要求進行身份驗證或加密。

如果您打算在生產中使用它,請不要忘記安全性。

相關問題