2013-05-11 47 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