Date header added

This commit is contained in:
Adrian Amaglio 2020-09-16 15:14:26 +02:00
parent 4fe3ce5652
commit 48333e8040

View File

@ -4,6 +4,7 @@ response = bottle.response
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.message import EmailMessage
import os # for environ vars
import sys # to print ot stderr
import re # to match our template system
@ -12,6 +13,7 @@ from dotenv import load_dotenv
import random, string # for tokens
import html # for sanitization
from bson.json_util import dumps
import datetime # For email date
##################################################### Bottle stuff ############################################
@ -191,12 +193,15 @@ def fill_fields(request, fields):
def send_mail (from_address, to, subject, content):
"""Actually connect to smtp server, build a message object and send it as a mail"""
msg = MIMEMultipart()
msg = EmailMessage()
msg['From'] = smtp_server_sender
msg.add_header('reply-to', from_address)
msg['To'] = to
msg['Subject'] = subject
msg.attach(MIMEText(content, 'plain', "utf-8"))
msg['Date'] = datetime.datetime.now()
msg.set_content(MIMEText(content, 'plain', "utf-8"))
#or
#msg.set_content(content)
# SMTP preambles
if security == 'ssl':