pallets-eco / flask-mail Goto Github PK
View Code? Open in Web Editor NEWFlask-Mail adds SMTP mail sending to your Flask applications
Home Page: https://flask-mail.readthedocs.io
License: BSD 3-Clause "New" or "Revised" License
Flask-Mail adds SMTP mail sending to your Flask applications
Home Page: https://flask-mail.readthedocs.io
License: BSD 3-Clause "New" or "Revised" License
http://pythonhosted.org/flask-mail/
http://pythonhosted.org/Flask-Mail/
looks like same url, but not same
http://pythonhosted.org/flask-mail/ : flask-mail 0.2
http://pythonhosted.org/Flask-Mail/ : flask-mail 0.9.0
We discussed this in a Flask-Security issue, but thought I'd put in an issue here to keep track. It would be helpful if you could use the Flask-Mail API to to send mail via a mail service, such as Google App Engine (https://developers.google.com/appengine/docs/python/mail/sendingmail) or Amazon SES (http://aws.amazon.com/ses/). I'm not overly familiar with SES, but it might require using 'boto' to access the API to send email.
This line https://github.com/mattupstate/flask-mail/blob/master/flask_mail.py#L385 don't work with Python3.4
With :
return self._message().as_string().encode(self.charset or 'utf-8')
Subject encoding work with success.
With :
return self._message().as_bytes()
Subject encoding fail.
I suggest to always use :
return self._message().as_string().encode(self.charset or 'utf-8')
I had another look at this issue for myself and it seems to boil down to not passing in the Cc & Bcc addresses along with the Recipients in the SMTP.sendmail call. Attached is a very small patch as potential fix. Essentially just added a property on the Message that throws the To, Cc & Bcc lists into a set and passes that as the recipient list to the SMTP.sendmail call.
Cheers,
Mark
I'd like to request a release with the latest commits.
msg['To'] = 'a,b <[email protected]>
will produce error, because comma separates recipients and must be escaped within one recipient.
How do I send an attachment with unicode characters in its filename.
I notice the option MAIL_ASCII_ATTACHMENTS
when set to True, strips the file names off their unicode characters.
But I want to able to send unicode characters in the filenames. Is there a way to do it?
i think thats not a nice thing to do
its pretty confusing to figure whats wrong when stuff goes wrong
I'm using nosetests with a setup_func that includes app.config['TESTING'] = True
and a teardown_func that includes app.config['TESTING'] = False
. Every test function is decorated with with_setup(setup_func, teardown_func)
.
My mails are still being sent even though TESTING is true. If I manually put if app.config['TESTING'] is False:
before my mail.send
's, my mails are not sent - which means that TESTING is indeed True during my tests.
Any ideas?
I'm having a bizarre issue when trying to use Gmail as a SMTP server. I have set MAIL_SERVER, MAIL_USERNAME, MAIL_PASSWORD AND MAIL_USE_TLS correctly, but I keep getting the following error:
SMTP AUTH extension not supported by server.}}}
{{{SMTP AUTH extension not supported by server.
At first glance, the original code is missing explicit helo()/ehlo() calls, but adding them doesn't seem help either.
The strange thing is, with the exact same parameters, a Fabric task "try_sending_mail" using smtplib directly seems to work just fine.
Here's the code for try_sending_mail(): http://gist.github.com/627275
Can you try and reproduce that with a Gmail account of yours using Flask-Mail? I must be either missing something badly, or there might be a little bug hidden in Flask-Mail.
I have the default mail sender set as a config variable. I use the python debuggingserver on my development box, and Sendmail on the server.
I'm sending email from a celery task. If I call the procedures directly without using celery, everything works fine. If I use celery, it errors out because it doesn't see DEFAULT_MAIL_SENDER.
I work around it by including this line: msg.sender = mail.app.config['DEFAULT_MAIL_SENDER']
Strangely, when I run it on the server, it works fine, even when called from a celery task.
Currently if a user creates a Message
object without a subject
defined, an error will occur later if the user tries to send the message.
When the message is checked for bad headers, it tries to iterate over the subject (which is a NoneType
object) and raises a TypeError exception.
Since this kind of error should be handled explictly and early, it seems best to do one of the following:
Message.send()
checking for the existence of subject
subject
a required argument during Message.__init__()
or assign a default value to subject
.I discovered today after a version upgrade and some debugging, flask-mail changed DEFAULT_MAIL_SENDER
to MAIL_DEFAULT_SENDER
. It should be explicit in changelog.
In changelog you have Changed configuration options to be less confusing
(6e55aad#diff-e4eb329834da3d36278b1b7d943b3bc9R12). This message does not help people upgrading the package.
To be clear, I'm not against this breaking change, just think it should be better documented.
A Relay class which handles mutliple messages per connection. This would be useful when sending bulk email messages e.g in a script or cronjob.
It would be used like this:
#!python
from flaskext.mail import Message, PersistentRelay
def send_bulk_emails(users, relay):
for user in users:
message = Message(recipients=[user.email])
# configure message
message.send(relay=relay)
relay = PersistentRelay()
with relay.connect():
send_bulk_emails(users, relay)
This line (blinker broadcast)
email_dispatched.send(message, app=current_app._get_current_object())
prevents conn.send(message)
(from with mailer.connect() as conn
)
for being used in acync queues (redis, for example) if I understand correctly.
It just freezes on app=current_app._get_current_object()
When I had commented it - queued messages started to come.
Feel free to correct me – I'm new to async programming.
Connection.exit() tries to call quit() even if there's no socket connection. "if self.host" should say "if self.host and getattr(self.host, 'sock', None)" to match the check in smtplib.SMTP.quit().
From docs/index.rst:
If the setting TESTING is set to True, emails will be suppressed. Calling send() on your messages will not result in any messages being actually sent.
Alternatively outside a testing environment you can set MAIL_SUPPRESS_SEND to False. This will have the same effect.
The text is confuse or wrong. "This will have the same effect" of what? If I set MAIL_SUPPRESS_SEND=False
, messages will be sent. The paragraph before this one says about "messages not sent".
Sometimes it raises, sometimes not!
Hi!
The trace back:
Exception on /projects/issues/tasks/add [POST]
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python2.7/dist-packages/flask_login.py", line 758, in decorated_view
return func(*args, **kwargs)
File "/app/Tasks/__init__.py", line 61, in addTask
send_mail(title, message, recipients)
File "/app/TimeFounder/utils.py", line 24, in send_mail
used.append(recipientTuple)
File "/usr/local/lib/python2.7/dist-packages/flask_mail.py", line 152, in __exit__
self.host.quit()
File "/usr/lib/python2.7/smtplib.py", line 756, in quit
res = self.docmd("quit")
File "/usr/lib/python2.7/smtplib.py", line 386, in docmd
self.putcmd(cmd, args)
File "/usr/lib/python2.7/smtplib.py", line 336, in putcmd
self.send(str)
File "/usr/lib/python2.7/smtplib.py", line 328, in send
raise SMTPServerDisconnected('please run connect() first')
SMTPServerDisconnected: please run connect() first
The code for this File "/app/TimeFounder/utils.py", line 24, in send_mail:
def send_mail(title, message, recipients):
if isinstance(message, dict):
template = env.get_template(message.pop('template'))
message = template(**message)
used = []
with mail.connect() as conn:
for recipient in recipients:
recipientTuple = (recipient.nick, recipient.email) if 'nick' in recipient else recipient
if recipientTuple not in used:
used.append(recipientTuple)
msg = Message(title, sender=(current_app.config['SENDER_NICK'],
current_app.config['EMAIL_SENDER']),
recipients=[recipientTuple], body=message)
conn.send(msg)
return used
Could someone point me what are what I'm missing here?
Thanks a lot
Flask-mail checks for newline in email which is actually perfectly valid and legal:
http://tools.ietf.org/html/rfc5322#section-2.2.3
Basically flask-mail fails to send certain correct mail.
I'm getting an error if MAIL_DEFAULT_SENDER
is a tuple:
MAIL_DEFAULT_SENDER = ("Just Testing", "[email protected]")
but it does work when using it like this:
msg = Message("Test 2", sender=("Just Testing", "[email protected]"), recipients=["[email protected]"])
Log:
send: 'ehlo [127.0.0.1]\r\n'
reply: '250-yggdrasil\r\n'
reply: '250-PIPELINING\r\n'
reply: '250-SIZE 10240000\r\n'
reply: '250-VRFY\r\n'
reply: '250-ETRN\r\n'
reply: '250-STARTTLS\r\n'
reply: '250-ENHANCEDSTATUSCODES\r\n'
reply: '250-8BITMIME\r\n'
reply: '250 DSN\r\n'
reply: retcode (250); Msg: yggdrasil
PIPELINING
SIZE 10240000
VRFY
ETRN
STARTTLS
ENHANCEDSTATUSCODES
8BITMIME
DSN
send: 'mail FROM:<Just [email protected]> size=794\r\n'
reply: '501 5.1.7 Bad sender address syntax\r\n'
reply: retcode (501); Msg: 5.1.7 Bad sender address syntax
send: 'rset\r\n'
reply: '250 2.0.0 Ok\r\n'
reply: retcode (250); Msg: 2.0.0 Ok
send: 'quit\r\n'
reply: '221 2.0.0 Bye\r\n'
reply: retcode (221); Msg: 2.0.0 Bye
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/var/apps/.virtualenvs/flaskbb/local/lib/python2.7/site-packages/flask_mail.py", line 416, in send
message.send(connection)
File "/var/apps/.virtualenvs/flaskbb/local/lib/python2.7/site-packages/flask_mail.py", line 351, in send
connection.send(self)
File "/var/apps/.virtualenvs/flaskbb/local/lib/python2.7/site-packages/flask_mail.py", line 168, in send
message.as_string())
File "/usr/lib/python2.7/smtplib.py", line 722, in sendmail
raise SMTPSenderRefused(code, resp, from_addr)
SMTPSenderRefused: (501, '5.1.7 Bad sender address syntax', ('Just Testing', '[email protected]'))
It just appends the sender name to the mail address.
Hello! I using Flask on pypy3 and all packages working well, except flask_mail. I have this error:
File "/usr/local/site-packages/flask_mail.py", line 41, in
from email import policy
ImportError: cannot import name 'policy'
We need another config variable (besides testing) to trigger suppress email sending. You might want to suppress all email sending in a development environment as well, but not have the TESTING flag set.
MAIL_SUPRESS_SEND = True/False
I have a block where I test the content of a mailing using with mail.record_messages() as outbox:
, but the mails are being sent even though it should be suppressed. if I hit that request normally without the ``with` block, mails do get suppressed.
For now, I've manually set mail.suppress = True.
Issue with CC / BCC emails not working. These params are lists.
The following:
self.cc = sanitize_address(cc) if cc is not None else None
self.bcc = sanitize_address(bcc) if bcc is not None else None
Should be changed as they are lists of email addresses.... i.e.:
self.cc = list([sanitize_address(recipient) for recipient in cc]) if cc is not None else None
self.bcc = list([sanitize_address(recipient) for recipient in bcc]) if bcc is not None else None
The current logic in flask_mail.Connection.send()
to convert flask_mail.Message
to a string then pass to SMTP.sendmail
is incorrect. And there's no test that actually cover the SMTP.sendmail
function.
smtplib
in >= Python3.2 comes with a SMTP.send_message
function, which contains the correct logic to convert a email.message.Message
to a byte string that SMTP.sendmail
accept.
Sample code to reproduce:
from __future__ import (unicode_literals, absolute_import,
division, print_function)
from MY_PROJECT import app
from flask.ext.mail import Mail, Message
mail = Mail(app)
text = '测试'
subject = "Your Weibo content request"
with mail.connect() as conn:
recipients = ['[email protected]']
msg = Message(subject, recipients=recipients,
sender="no-reply@localhost")
msg.body = text
conn.send(msg)
Corresponding traceback
Traceback (most recent call last):
File "test.py", line 24, in <module>
conn.send(msg)
File "/data/web/cgi-bin/venv/lib/python3.4/site-packages/flask_mail.py", line 168, in send
message.as_string())
File "/data/web/cgi-bin/python-3.4.0/lib/python3.4/smtplib.py", line 752, in sendmail
msg = _fix_eols(msg).encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 284-285: ordinal not in range(128)
--> #50
Flask-Mail depends on Lamson, which depends on python-daemon, which is Unix only. Since I don't need a full email server like Lamson, this seems to be an unnecessary restriction.
Windows install log (running under virtualenv):
Downloading/unpacking python-daemon (from Lamson->Flask-Mail)
Downloading python-daemon-1.6.tar.gz (41Kb): 41Kb downloaded
Running setup.py egg_info for package python-daemon
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "c:\Code\pythonenv\build\python-daemon\setup.py", line 22, in
<module>
main_module = __import__(main_module_name, fromlist=['version'])
File "daemon\__init__.py", line 43, in <module>
from .daemon import DaemonContext
File "daemon\daemon.py", line 25, in <module>
import resource
ImportError: No module named resource
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "c:\Code\pythonenv\build\python-daemon\setup.py", line 22, in <mod
ule>
main_module = __import__(main_module_name, fromlist=['version'])
File "daemon\__init__.py", line 43, in <module>
from .daemon import DaemonContext
File "daemon\daemon.py", line 25, in <module>
import resource
ImportError: No module named resource
----------------------------------------
Command python setup.py egg_info failed with error code 1
Master branch has important fix. I want it to install using pip at my production environment.
I'd like to have a way to add custom X-Headers. For example, see SendGrid's documentation for category tracking by using an X-SMTPAPI header: http://docs.sendgrid.com/documentation/delivery-metrics/categories/
at line 360 msg[k] = v should be more like msg[k] = str(v)
I've successfully setup flask-mail on heroku and it works wonderfully however when I look through my logs on heroku I have a lot of lines like this
Oct 04 08:06:59 app/web.1: reply: '250 Delivery in progress\r\n'
Oct 04 08:06:59 app/web.1: reply: retcode (250); Msg: Delivery in progress
Oct 04 08:06:59 app/web.1: data: (250, 'Delivery in progress')
Oct 04 08:06:59 app/web.1: send: 'quit\r\n'
Oct 04 08:06:59 app/web.1: send: 'ehlo af97c6b6-a4f1-4720-b12e-5ba6ff1981a2.prvt.dyno.rt.heroku.com\r\n'
Oct 04 08:06:59 app/web.1: reply: '250 Sender address accepted\r\n'
Oct 04 08:06:59 app/web.1: reply: retcode (250); Msg: Sender address accepted
Oct 04 08:06:59 app/web.1: send: 'rcpt TO:@outlook.com\r\n'
Oct 04 08:06:59 app/web.1: reply: '250-54.167.136.202\r\n'
Oct 04 08:06:59 app/web.1: reply: '250-8BITMIME\r\n'
Oct 04 08:06:59 app/web.1: reply: '250-SIZE 20480000\r\n'
Oct 04 08:06:59 app/web.1: reply: '250-AUTH=PLAIN LOGIN\r\n'
Oct 04 08:06:59 app/web.1: reply: '250-AUTH PLAIN LOGIN\r\n'
Oct 04 08:06:59 app/web.1: reply: '250 STARTTLS\r\n'
Oct 04 08:06:59 app/web.1: reply: retcode (250); Msg: 54.167.136.202
Oct 04 08:06:59 app/web.1: 8BITMIME
Oct 04 08:06:59 app/web.1: SIZE 20480000
Oct 04 08:06:59 app/web.1: AUTH=PLAIN LOGIN
Oct 04 08:06:59 app/web.1: AUTH PLAIN LOGIN
Oct 04 08:06:59 app/web.1: STARTTLS
Oct 04 08:06:59 app/web.1: send: 'STARTTLS\r\n'
Oct 04 08:06:59 app/web.1: reply: '250 Delivery in progress\r\n'
Oct 04 08:06:59 app/web.1: reply: retcode (250); Msg: Delivery in progress
Oct 04 08:06:59 app/web.1: data: (250, 'Delivery in progress')
Oct 04 08:06:59 app/web.1: send: 'quit\r\n'
Oct 04 08:06:59 app/web.1: reply: '220 Begin TLS negotiation now\r\n'
Oct 04 08:06:59 app/web.1: reply: retcode (220); Msg: Begin TLS negotiation now
Oct 04 08:06:59 app/web.1: reply: '221 See you later\r\n'
Oct 04 08:06:59 app/web.1: reply: retcode (221); Msg: See you later
Oct 04 08:06:59 app/web.1: reply: '235 Authentication successful.\r\n'
Oct 04 08:06:59 app/web.1: reply: retcode (235); Msg: Authentication successful.
Oct 04 08:06:59 app/web.1: send: 'mail FROM:<> size=1448\r\n'
Oct 04 08:06:59 app/web.1: reply: '250 Delivery in progress\r\n'
Is it possible to suppress this?
the line 46 should be
host.set_debuglevel(int(self.mail.debug))
instead of:
host.set_debuglevel(int(self.app.debug))
to allow MAIL_DEBUG to take effect independently of Flask debug flag
See http://flask.pocoo.org/docs/api/#flask.Flask.extensions
I have a custom (Localized) reset email format that we use for Flask-Security. It looks like send_reset_password_instructions
results in a UnicodeEncodeError
when the recipient (TO) contains Unicode characters (in this case —
).
I believe this is related to #53
... stuff here...
File "./server/auth/endpoints.py" line 88 in reset_password send_reset_password_instructions(user)
File "/var/www/myserver/env/src/flask-security/flask_security/recoverable.py" line 36 in send_reset_password_instructions user=user, reset_link=reset_link)
File "/var/www/myserver/env/src/flask-security/flask_security/utils.py" line 304 in send_mail mail.send(msg)
File "/var/www/myserver/env/local/lib/python2.7/site-packages/flask_mail.py" line 416 in send message.send(connection)
File "/var/www/myserver/env/local/lib/python2.7/site-packages/flask_mail.py" line 351 in send connection.send(self)
File "/var/www/myserver/env/local/lib/python2.7/site-packages/flask_mail.py" line 168 in send message.as_string())
File "/usr/lib/python2.7/smtplib.py" line 727 in sendmail (code, resp) = self.rcpt(each, rcpt_options)
File "/usr/lib/python2.7/smtplib.py" line 479 in rcpt self.putcmd("rcpt", "TO:%s%s" % (quoteaddr(recip), optionlist))
File "/usr/lib/python2.7/smtplib.py" line 334 in putcmd self.send(str)
File "/usr/lib/python2.7/smtplib.py" line 321 in send self.sock.sendall(str)
File "/usr/lib/python2.7/ssl.py" line 229 in sendall v = self.send(data[count:])
File "/usr/lib/python2.7/ssl.py" line 198 in send v = self._sslobj.write(data)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2014' in position 16: ordinal not in range(128)
When using the mailer to send an e-mail from a background worker (that is, outside of the Flask application context), it crashes and burns.
I have an app that is sending bulk emails using the DEFAULT_MAIL_SENDER. I just updated to 0.8.1 and changed the config to MAIL_DEFAULT_SENDER but the bulk emails have stopped working. It looks like Message.Send() is using the MAIL_DEFAULT_SENDER if needed, but Connection.Send() is not. Previously the Message.sender was set from the DEFAULT_MAIL_SENDER when the message was created so it didn't matter. The error log is below.
TypeError Traceback (most recent call last)
in ()
1 with mail.connect() as conn:
----> 2 conn.send(msg)
3
/home/jmapes/.virtualenvs/astdash/local/lib/python2.7/site-packages/flask_mail.pyc in send(self, message)
138 self.host.sendmail(message.sender,
139 message.send_to,
--> 140 message.as_string())
141
142 email_dispatched.send(message, app=current_app._get_current_object())
/home/jmapes/.virtualenvs/astdash/local/lib/python2.7/site-packages/flask_mail.pyc in as_string(self)
266
267 msg['Subject'] = self.subject
--> 268 msg['From'] = sanitize_address(self.sender)
269 msg['To'] = ', '.join(list(set(sanitize_addresses(self.recipients))))
270
/home/jmapes/.virtualenvs/astdash/local/lib/python2.7/site-packages/flask_mail.pyc in sanitize_address(addr, encoding)
64 if isinstance(addr, basestring):
65 addr = parseaddr(force_text(addr))
---> 66 nm, addr = addr
67
68 # This try-except clause is needed on Python 3 < 3.2.4
TypeError: 'NoneType' object is not iterable
When searching for your library I found this web page in the first place: http://pythonhosted.org/flask-mail/ , which seems to be an older version of your actual home page: https://pythonhosted.org/Flask-Mail/ (see the case difference ?)
That made me loose a lot of time because information on that page are mostly outdated. The code examples are wrong and it does not even indicate the correct repository (it still points to a bitbucket repo not edited since 4 years). I was very very close to decree that the documentation of this lib was shitty and that I didn't wanted to use it before I found your github repo.
So... you should probably remove that old home page and add a redirection to the new one.
The docs specifically mention that TESTING can be used to store messages in the outbox instead of sending them directly. This does not work for me, however, as the g.outbox functionality seems not present.
Many things seem undocumented, for example options like MAIL_FAIL_SILENTLY or the email_dispatched signal.
I have not found a way described in the docs that allows me to test sending emails without actually sending them. Please update the documentation to reflect the current state of Flask-Mail, if the extension is still maintained.
It would be nice to allow to set custom Connection class. I need some tweaks so I could just subclass it, but there is no way how to tell flask-mail it should use my implementation. I think the change would be very easy and it would provide more extensibility. Now the only way is monkeypatching, which is ugly.
In
https://github.com/mattupstate/flask-mail/blob/master/flask_mail.py#L82
there is a variable strings_only which is not defined anywhere.
What did I miss?
Can this be removed?
If the email address is unicode and contains non-ASCII characters, a UnicodeEncodeError is raised:
>>> mail.send_message(subject=u'Subject', recipients=[u'föö@bär.com'], body=u'Body')
Traceback (most recent call last)
File "<stdin>", line 1, in <module>
File "/app/.heroku/venv/lib/python2.7/site-packages/flask_mail.pyc", line 427 in send_message
self.send(Message(*args, **kwargs))
File "/app/.heroku/venv/lib/python2.7/site-packages/flask_mail.pyc", line 416, in send
message.send(connection)
File "/app/.heroku/venv/lib/python2.7/site-packages/flask_mail.pyc", line 306, in send
connection.send(self)
File "/app/.heroku/venv/lib/python2.7/site-packages/flask_mail.pyc", line 91, in send
message.as_string())
File "/usr/local/lib/python2.7/smtplib.pyc", line 718 in sendmail
(code, resp) = self.rcpt(each, rcpt_options)
File "/usr/local/lib/python2.7/smtplib.pyc", line 470, in rcpt
self.putcmd("rcpt", "TO:%s%s" % (quoteaddr(recip), optionlist))
File "/usr/local/lib/python2.7/smtplib.pyc", line 327, in putcmd
self.send(str)
File "/usr/local/lib/python2.7/smtplib.pyc", line 314 in send
self.sock.sendall(str)
File "/usr/local/lib/python2.7/ssl.pyc", line 220, in sendall
v = self.send(data[count:])
File "/usr/local/lib/python2.7/ssl.pyc", line 189, in send
v = self._sslobj.write(data)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 10-11: ordinal not in range(128)
If the recipient is a str
object encoded with UTF-8, the SMTP server responds with syntax error since non-ASCII characters are illegal.
>>> mail.send_message(subject='Subject', recipients=['föö@bär.com'], body=u'Test')
Traceback (most recent call last)
File "<stdin>", line 1, in <module>
File "/app/.heroku/venv/lib/python2.7/site-packages/flask_mail.pyc", line 427, in send_message
self.send(Message(*args, **kwargs))
File "/app/.heroku/venv/lib/python2.7/site-packages/flask_mail.pyc", line 416, in send
message.send(connection)
File "/app/.heroku/venv/lib/python2.7/site-packages/flask_mail.pyc", line 306, in send
connection.send(self)
File "/app/.heroku/venv/lib/python2.7/site-packages/flask_mail.pyc", line 91, in send
message.as_string())
File "/usr/local/lib/python2.7/smtplib.pyc", line 724, in sendmail
raise SMTPRecipientsRefused(senderrs)
SMTPRecipientsRefused: {'f\xc3\xb6\xc3\xb6@b\xc3\xa4r.com': (501, 'Syntax error')}
For reference, non-ASCII characters in email addresses are handled like this in Django:
https://github.com/django/django/blob/master/django/core/mail/message.py#L99
need to set content id for attachments to be able to embed images using cid method
also the line 373 should be changed to:
for key, value in attachment.headers.items():
need the .items():
The documentation in .readthedocs.org is outdated. Please, upgrade it when you have some time.
Thanks!
In addition to one connection per email and the bulk mode, when dealing with a high volume of user-driven email-sending tasks, it will be nice for Flask-Mail to maintain a connection pool.
RIght now the str and repr are the same:
'<flaskext.mail.message.Message object at 0x1020171d0>'
Perhaps it could have nice str() (or unicode?) function that gives a mutt-style view of the message and headers.
If this is desired, I would be happy to implement.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.