我想学习 yii 作为我的第一个框架.我正在尝试使联系表正常工作.但我得到了这个错误:
I want to learn yii as my first framework. And I'm trying to make the contact form work. But I got this error:
我已经从以下位置配置了 php.ini 文件:
I've already configured php.ini file from:
C:wampinphpphp5.3.0
并将默认值更改为这些值:
And changed the default to these values:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = ssl:smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 23
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = myemail@gmail.com
我从这里看到 gmail 不使用端口 25,这是 php.ini 中的默认端口.所以我使用了 23.并且还在 windows 7 防火墙中打开了该端口.通过入站规则.
I've seen from here that gmail doesn't use port 25, which is the default in the php.ini. So I used 23. And also opened that port in the windows 7 firewall. Via inbound rules.
然后我还在我的 yii 应用程序中编辑了主配置,以匹配我正在使用的电子邮件:
Then I also edited the main config in my yii application, to match the email that I'm using:
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'myemail@gmail.com',
),
);
最后,我重新启动了 wampserver.然后清除了我所有的浏览数据.为什么我仍然看到它在错误中指出端口 25.我错过了什么吗?请帮忙.
Finally, I restarted wampserver. Then cleared all my browsing data. Why then to I still see that its pointing out port 25 in the error. Have I miss something? Please help.
这是一个简单的 python 脚本,可以让你在 localhost 上运行邮件服务器,你不需要做任何改变.对不起,如果我有点晚了.
Heres a simple python script which could allow you to run a mail server on localhost, you dont have to change anything. Sorry if im a bit late.
import smtpd
import smtplib
import asyncore
class SMTPServer(smtpd.SMTPServer):
def __init__(*args, **kwargs):
print "Running fake smtp server on port 25"
smtpd.SMTPServer.__init__(*args, **kwargs)
def process_message(*args, **kwargs):
to = args[3][0]
msg = args[4]
gmail_user = 'yourgmailhere'
gmail_pwd = 'yourgmailpassword'
smtpserver = smtplib.SMTP("smtp.gmail.com",587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login(gmail_user, gmail_pwd)
smtpserver.sendmail(gmail_user, to, msg)
print 'sent to '+to
pass
if __name__ == "__main__":
smtp_server = SMTPServer(('localhost', 25), None)
try:
asyncore.loop()
except KeyboardInterrupt:
smtp_server.close()
#end of code
注意:我使用 args[3][0] 和 args[4] 作为地址和消息,因为我的 php mail() 发送的 args 对应于一个 args[3][0] 数组作为接收电子邮件
Note: I used args[3][0] and args[4] as to address and message as the args sent by my php mail() corresponded to an array of args[3][0] as receipent email
这篇关于如何配置 php.ini 以使用 gmail 作为邮件服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!