use*_*269 11 php gmail smtp wamp
我想学习yii作为我的第一个框架.我正在努力使联系表格有效.但我得到了这个错误:

我已经从以下位置配置了php.ini文件:
C:\wamp\bin\php\php5.3.0
Run Code Online (Sandbox Code Playgroud)
并将默认值更改为以下值:
[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
Run Code Online (Sandbox Code Playgroud)
我从这里看到gmail不使用端口25,这是php.ini中的默认端口.所以我用了23.而且还在windows 7防火墙中打开了那个端口.通过入站规则.
然后我也编辑了我的yii应用程序中的主配置,以匹配我正在使用的电子邮件:
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'myemail@gmail.com',
),
);
Run Code Online (Sandbox Code Playgroud)
最后,我重新启动了wampserver.然后清除了我的所有浏览数据.为什么然后我仍然看到它指出错误中的端口25.我错过了什么吗?请帮忙.
这是一个简单的python脚本,可以让您在本地主机上运行邮件服务器,而无需进行任何更改。对不起,如果我迟到了。
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
Run Code Online (Sandbox Code Playgroud)
注意:我使用args [3] [0]和args [4]作为地址和消息,因为我的php mail()发送的args对应于args [3] [0]的数组作为回执电子邮件
小智 0
如果使用 WAMP,要配置的 php.ini 位于 wamp/bin/apache/Apache_x_y/bin 文件夹中
其中 _x_y 与您的 wamp 安装使用的 Apache 版本相关
| 归档时间: |
|
| 查看次数: |
74936 次 |
| 最近记录: |