Module mail : Add Date header (#59080)

* Mail module : add date header (#58808)
This commit is contained in:
Jonathan 2019-07-16 16:56:00 +02:00 committed by Brian Coca
parent de66abe521
commit f0eaf1fb39
2 changed files with 4 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- Add date header to the email based on local time in mail module (https://github.com/ansible/ansible/issues/58808).

View file

@ -203,7 +203,7 @@ import smtplib
import ssl
import traceback
from email import encoders
from email.utils import parseaddr, formataddr
from email.utils import parseaddr, formataddr, formatdate
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@ -326,6 +326,7 @@ def main():
msg = MIMEMultipart(_charset=charset)
msg['From'] = formataddr((sender_phrase, sender_addr))
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = Header(subject, charset)
msg.preamble = "Multipart message"