Commit 1bb6403a authored by Kamal Dodiya's avatar Kamal Dodiya
Browse files

Fix request without attachment

parent 0117fa00
Pipeline #185752 failed with stages
in 1 minute and 27 seconds
......@@ -35,12 +35,13 @@ async def send_email_wtih_attachment_async(tq):
message["Subject"] = f"{tq['subject']} - {tq['request'].headers['Host']}"
body = await format_message(tq)
message.set_content(body)
for attachment in tq["files"]:
maintype, subtype = attachment.content_type.split('/', 1)
message.add_attachment(attachment.file.read(),
maintype=maintype,
subtype=subtype,
filename=attachment.filename)
if tq["files"] is not None:
for attachment in tq["files"]:
maintype, subtype = attachment.content_type.split('/', 1)
message.add_attachment(attachment.file.read(),
maintype=maintype,
subtype=subtype,
filename=attachment.filename)
await aiosmtplib.send(message, hostname=Envs.MAIL_SERVER, port=Envs.MAIL_PORT)
logger.info(f"The email sent successfully for {tq['email']}")
return True
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment