import requests
from marrow.mailer import Mailer, Message
from app import celery
from app.helpers.versioning import strip_tags
@celery.task(name='send.email.post.smtp')
def send_mail_via_smtp_task(config, payload):
print config,payload
mailer_config = {
'transport': {
'use': 'smtp',
'host': config['host'],
'username': 'nikhil.rayaprolu@students.iiit.ac.in',
'password': '99121Padma',
'tls': config['encryption'],
'port': config['port']
}
}
mailer = Mailer(mailer_config)
mailer.start()
message = Message(author=payload['from'], to=payload['to'])
message.subject = payload['subject']
message.plain = strip_tags(payload['html'])
message.rich = payload['html']
mailer.send(message)
mailer.stop()
上面的代码给了我一个错误 ERROR/MainProcess] Task send.email.post.smtp[a58e3232-ffe2-42d0-ad53-03dc4dc6b980] 引发了意外:KeyError('encryption',) 是什么导致了这里的问题?