mirror of
https://github.com/almet/copanier.git
synced 2025-04-28 11:32:38 +02:00
Fixes email sending.
Now works with HTML + alternative plain text + attachments.
This commit is contained in:
parent
cfd9543d92
commit
1cbdc56969
1 changed files with 6 additions and 4 deletions
|
@ -13,10 +13,7 @@ def send(to, subject, body, html=None, copy=None, attachments=None):
|
|||
if not attachments:
|
||||
attachments = []
|
||||
|
||||
msg = MIMEMultipart()
|
||||
msg.attach(MIMEText(body, "plain"))
|
||||
if html:
|
||||
msg.attach(MIMEText(html, "html"))
|
||||
msg = MIMEMultipart('alternative')
|
||||
msg["Subject"] = subject
|
||||
msg["From"] = config.FROM_EMAIL
|
||||
msg["To"] = to
|
||||
|
@ -30,6 +27,11 @@ def send(to, subject, body, html=None, copy=None, attachments=None):
|
|||
filename=file_name)
|
||||
encoders.encode_base64(part)
|
||||
msg.attach(part)
|
||||
|
||||
msg.attach(MIMEText(body, "plain"))
|
||||
if html:
|
||||
msg.attach(MIMEText(html, "html"))
|
||||
|
||||
if not config.SEND_EMAILS:
|
||||
return print("Sending email", str(body))
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue