pallets-eco/flask-mail

send attach excel raise SMTPDataError

Closed this issue · 1 comments

`from flask import Flask
from flask_mail import Mail,Message

app = Flask(name)
app.config["MAIL_SERVER"] = "smtp.163.com"
app.config["MAIL_USERNAME"] = "myemail@163.com"
app.config["MAIL_PASSWORD"] = "myemail"
app.config["MAIL_ASCII_ATTACHMENTS "] = True
mail = Mail(app)

@app.route('/')
def test():
title = 'warning test'
msg = Message(title, sender=('administrator', 'myemail@163.com'), recipients=['otheremail@163.com'])
msg.attach(filename="test.csv",data=b"fooba,hello", content_type='text/csv')
#msg.attach("test.csv",'"aaa","bbb","ccc","nddd","eee","fff"',"text/csv")
mail.send(msg)
return "haoba,haoba"

if name == 'main':
app.run(host='0.0.0.0',port=8888)`

i want to send csv attach ,but raise SMTPDataError

the error:
[2018-05-31 12:03:43,783] ERROR in app: Exception on / [GET] Traceback (most recent call last): File "C:\Users\luowq\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1982, in wsgi_app response = self.full_dispatch_request() File "C:\Users\luowq\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\luowq\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Users\luowq\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\_compat.py", line 33, in reraise raise value File "C:\Users\luowq\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\luowq\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "E:/src/python/monitor/q.py", line 25, in test mail.send(msg) File "C:\Users\luowq\AppData\Local\Programs\Python\Python36\lib\site-packages\flask_mail.py", line 492, in send message.send(connection) File "C:\Users\luowq\AppData\Local\Programs\Python\Python36\lib\site-packages\flask_mail.py", line 427, in send connection.send(self) File "C:\Users\luowq\AppData\Local\Programs\Python\Python36\lib\site-packages\flask_mail.py", line 192, in send message.rcpt_options) File "C:\Users\luowq\AppData\Local\Programs\Python\Python36\lib\smtplib.py", line 888, in sendmail raise SMTPDataError(code, resp) smtplib.SMTPDataError: (554, b'DT:SPM 163 smtp7,C8CowADHKQw4dA9b0_xbDg--.43717S2 1527739449,please see http://mail.163.com/help/help_spam_16.htm?ip=219.159.152.25&hostid=smtp7&time=1527739449')

What should i solved?

I can't reproduce this issue.