mirror of
https://github.com/almet/copanier.git
synced 2025-04-28 19:42:37 +02:00
Fix email sending
This commit is contained in:
parent
3c39221a2d
commit
cfd9543d92
1 changed files with 4 additions and 1 deletions
|
@ -10,6 +10,9 @@ from . import config
|
||||||
|
|
||||||
|
|
||||||
def send(to, subject, body, html=None, copy=None, attachments=None):
|
def send(to, subject, body, html=None, copy=None, attachments=None):
|
||||||
|
if not attachments:
|
||||||
|
attachments = []
|
||||||
|
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
msg.attach(MIMEText(body, "plain"))
|
msg.attach(MIMEText(body, "plain"))
|
||||||
if html:
|
if html:
|
||||||
|
@ -28,7 +31,7 @@ def send(to, subject, body, html=None, copy=None, attachments=None):
|
||||||
encoders.encode_base64(part)
|
encoders.encode_base64(part)
|
||||||
msg.attach(part)
|
msg.attach(part)
|
||||||
if not config.SEND_EMAILS:
|
if not config.SEND_EMAILS:
|
||||||
return print("Sending email", str(msg))
|
return print("Sending email", str(body))
|
||||||
try:
|
try:
|
||||||
server = smtplib.SMTP_SSL(config.SMTP_HOST)
|
server = smtplib.SMTP_SSL(config.SMTP_HOST)
|
||||||
server.login(config.SMTP_LOGIN, config.SMTP_PASSWORD)
|
server.login(config.SMTP_LOGIN, config.SMTP_PASSWORD)
|
||||||
|
|
Loading…
Reference in a new issue