Date header added
This commit is contained in:
parent
4fe3ce5652
commit
48333e8040
11
main.py
11
main.py
@ -4,6 +4,7 @@ response = bottle.response
|
|||||||
import smtplib
|
import smtplib
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
|
from email.message import EmailMessage
|
||||||
import os # for environ vars
|
import os # for environ vars
|
||||||
import sys # to print ot stderr
|
import sys # to print ot stderr
|
||||||
import re # to match our template system
|
import re # to match our template system
|
||||||
@ -12,6 +13,7 @@ from dotenv import load_dotenv
|
|||||||
import random, string # for tokens
|
import random, string # for tokens
|
||||||
import html # for sanitization
|
import html # for sanitization
|
||||||
from bson.json_util import dumps
|
from bson.json_util import dumps
|
||||||
|
import datetime # For email date
|
||||||
|
|
||||||
|
|
||||||
##################################################### Bottle stuff ############################################
|
##################################################### Bottle stuff ############################################
|
||||||
@ -189,14 +191,17 @@ def fill_fields(request, fields):
|
|||||||
raise MissingParameterException("Le champs {} est obligatoire".format(field))
|
raise MissingParameterException("Le champs {} est obligatoire".format(field))
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
def send_mail(from_address, to, subject, content):
|
def send_mail (from_address, to, subject, content):
|
||||||
"""Actually connect to smtp server, build a message object and send it as a mail"""
|
"""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['From'] = smtp_server_sender
|
||||||
msg.add_header('reply-to', from_address)
|
msg.add_header('reply-to', from_address)
|
||||||
msg['To'] = to
|
msg['To'] = to
|
||||||
msg['Subject'] = subject
|
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
|
# SMTP preambles
|
||||||
if security == 'ssl':
|
if security == 'ssl':
|
||||||
|
Loading…
Reference in New Issue
Block a user