2013-05-11 148 views
2

我必須發送電子郵件給gamil,以便在我的網站上註冊帳戶。我正在使用wamp,贏了7,codeigniter。並通過sendmail發送郵件。我已完成所有必要的更改即在php codeigniter中發送郵件給gmail

在php.ini

; For Win32 only. 
SMTP = smtp.gmail.com 
smtp_port = 465 
; For Win32 only. 
;sendmail_from = [email protected] 
sendmail_path ="C:\wamp\sendmail\sendmail.exe -t" 

而且在sendmail.ini

smtp_server=smtp.gmail.com 
smtp_port=465 
[email protected] 
auth_password=mypassword 

但它顯示了這個錯誤,而不是發送電子郵件。

消息:電子郵件():無法連接在 「localhost」 的端口25的郵件服務器,驗證您的 「SMTP」 和 「SMTP_PORT」 在php.ini中設置或使用的ini_set() 文件名:庫/ Email.php

它仍然在端口25上發生錯誤,但我正在使用端口465.這可能是什麼原因?我做錯了什麼? 任何幫助。

+0

你不必使用「sendmail」程序。將php.ini重置爲前一個,並簡單地使用codeigniter發送郵件;請按照http://stackoverflow.com/a/1622996中的說明進行操作。如果您使用codeigniter,則不需要localhost服務器上的額外配置(codeigniter已經有內置的php郵件程序庫)。 – 2013-07-28 17:33:21

回答

1

我只是在C:\wamp\bin\apache\apache2.2.22\bin\php.ini,而不是C:\wamp\bin\php\php.ini做出這些變化。它的工作原理:)

0

我認爲你必須重新啓動你的服務器。

編輯 我發現this thread與soulution:

Add the following code to the top of your email script if your mail script continues to fail. 


// Please specify your Mail Server - Example: mail.yourdomain.com. 
ini_set("SMTP","mail.YourDomain.com"); 

// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports. 
ini_set("smtp_port","25"); 

// Please specify the return address to use 
ini_set('sendmail_from', '[email protected]'); 
+0

我已經更新了我的答案。 – 2013-05-11 13:31:41

+0

@ Daniel,這些步驟與我在php.ini文件中進行的更改相同。 – bkashaf 2013-05-11 13:32:16

+0

我知道,但該線程的作者說,他也有他的php.ini中正確的配置 - 「但是,我的php.ini配置正確」。祝你今天愉快。 – 2013-05-11 13:33:20