各位大大,是不是我的服务器需要配置什么端口之类的?搞了两天了,无法搞好!
代码如下:
from flask import Flask
# from run_celery import make_celery
# from celery import platforms
from flask_mail import Mail,Message
app = Flask(__name__)
app.config.update(
# CELERY_BROKER_URL='redis://localhost:6379/0',
# CELERY_RESULT_BACKEND='redis://localhost:6379/1',
DEBUG = True,
MAIL_SERVER='smtp.qq.com',
MAIL_PROT='25',
# MAIL_USE_SSL = True,
MAIL_USE_TLS = True,
MAIL_USERNAME = '[email protected]',
MAIL_PASSWORD = 'rkuynjxxxxxpqicfc',
MAIL_DEBUG = True
)
# celery = make_celery(app)
mail = Mail(app)
@app.route('/')
def index():
msg = Message("This is only test Mail",sender='[email protected]',recipients=['[email protected]'])
msg.body = "This is my first Mail."
mail.send(msg)
print('Mail send OK')
return 'sent'
if __name__ == '__main__':
app.run()
server {
listen 80;
server_name www.demo.com;
access_log /wwwlogs/www.demo.com_nginx.log combined;
index index.html index.htm index.php;
root /wwwroot/www.demo.com;
location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|swf|flv|mp4)$ {
valid_referers none blocked *.demo.com www.demo.com;
if ($invalid_referer) {
return 403;
}
}
location / {
try_files $uri @flask;
}
location @flask {
proxy_set_header X-real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:5000;
}
location ~ .*\.(bmp|swf|flv|mp4)$ {
expires 30d;
access_log off;
}
location ~ /\.ht {
deny all;
}
}
1
infun 2017-11-06 23:35:33 +08:00
qq 邮箱的密码是特殊设置的,不是登录密码
& 即便成功了,发几份邮件之后就提示垃圾邮件了 |
3
oyhw92 2017-11-06 23:45:39 +08:00 via iPhone
看看服务器运营商是不是封锁了 25 端口,google cloud 就封了,自家 gmail 都不行,只能找第三方邮件平台
|
6
lt0136 2017-11-07 00:10:40 +08:00 via Android
现在各种云都禁止 25 端口了
|
8
cy97cool 2017-11-07 09:57:14 +08:00
即使封了 25 端口也没关系吧 改用 SSL 的 465 端口或 587 端口即可
https://kf.qq.com/faq/120322fu63YV130422nqIrqu.html 对应的 flask 配置加一条 MAIL_USE_SSL = True |
10
TruMps 2019-07-29 17:39:04 +08:00
换 587 端口~
|