2014-09-11 91 views
1

會有人能夠幫助我與我的question..I我不能夠在php..Here使用電子郵件()發送郵件發送郵件是我的代碼:無法使用郵件功能在PHP

if (isset($_POST["from"])) { 
    $from = $_POST["from"]; // sender 
    $subject = $_POST["subject"]; 
    $message = $_POST["message"]; 
    $message = wordwrap($message, 70); 
    mail("[email protected]",$subject,$message,"From: $from\n"); 
    echo "Thank you for sending us feedback"; 
} 

當我在本地主機上運行此程序時,輸出顯示爲「感謝您向我們發送反饋」,但未收到[email protected]中的任何郵件。

+2

如果沒有SMTP設置,mail()函數將無法在您的本地主機上運行。 – 2014-09-11 09:54:42

+0

http://stackoverflow.com/questions/14802606/mail-function-is-not-working-in-localhost-server ?? – user3065301 2014-09-11 09:56:15

+0

你可以在本地主機上配置smtp服務器嗎? – rikpg 2014-09-11 09:57:18

回答

2

檢查你的php.ini cofiguration文件,並添加郵件服務器的配置:

SMTP = server ; mail server 
smtp_port = 25 ; port 
sendmail_from = [email protected] ; 

或者

使用PHPMailer的https://github.com/PHPMailer/PHPMailer通過Gmail,雅虎或任何外部郵件服務器來發送。

+0

我使用PHP郵件程序。謝謝 – 2014-09-12 03:56:06