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': '[email protected]',
'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()
the above code is giving me an error ERROR/MainProcess] Task send.email.post.smtp[a58e3232-ffe2-42d0-ad53-03dc4dc6b980] raised unexpected: KeyError('encryption',) what's causing the problem here?
The error says
config
dictionary does not have a key namedencryption
, so when you trying to get the value of this key raising theKeyError
. Make sureconfig
dictionary have it.