2012-07-25 142 views
0

在主題..!用xampp在本地發送電子郵件到gmail帳戶,沒有錯誤,但電子郵件沒有到達

我配置我的文件在php.ini

SMTP =smtp.gmail.com 
    smtp_port = 587 
    sendmail_from = my [email protected] 
    sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 

,並在sendmail.ini

smtp_server=smtp.gmail.com 
    smtp_port=587 
    smtp_ssl=tls 
    auth_username=(my adress @gmail.com) 
    auth_password=(here my gamil account password) 

如下

是明確的,你可以在這裏看到我的PHP代碼!

 $headers = "MIME-Version: 1.0" . "\r\n"; 
     $headers .= "Content-type: text/html; charset=iso-8859-1"."\r\n"; 
     $headers .="From: my adress @gmail.com"."\r\n"; 

     $subject = "Your New Password"; 
     $message = "Your new password is as follows: 
     ---------------------------- 
     Password: $emailpassword 
     ---------------------------- 
     Please make note this information has been encrypted into our database 

     This email was automatically generated."; 



     if(!mail($forgotpassword, $subject, $message, $headers)){ 
     die ("Sending Email Failed, Please Contact Site Admin! ($site_email)"); 
     }else{ 
      print'New Password Sent!.'; 
    } 

我發送的是新密碼發送!

沒有錯誤 如果真的已經發送了 但是當我檢查電子郵件時,沒有消息!

注意:我在windows-7上運行

謝謝。

+1

本地您不允許聯繫gmail SMTP服務器。您只能訪問您自己的Internet提供商的SMTP服務器。 – RTB 2012-07-25 09:06:44

+0

@RTB謝謝..然後,我想我會推遲測試,直到我將其上傳到服務器 – proG 2012-07-25 09:19:27

回答

0

本地不允許聯繫gmail SMTP服務器。您只能訪問您自己的Internet提供商的SMTP服務器。但是,您可以在本地安裝簡單的SMTP服務器like this one

在一些網絡中,這將允許您從xampp本地發送郵件到您本地安裝的SMTP服務器,並從那裏到互聯網。

+0

謝謝!但你能告訴我如何配置它嗎?在php.ini中,我是新來的這個東西:$ – proG 2012-07-25 10:31:45

+0

謝謝!但你能告訴我如何配置它嗎?在php.ini,因爲我是新來的這個東西:$ – proG 2012-07-25 10:40:03

+0

有沒有必要配置php.ini只是使用這樣的庫:http://phpmailer.worxware.com/index.php這也產生所有的頭代碼給你。這節省了大量的編碼。 – RTB 2012-07-25 11:39:07

相關問題