Module mail : Add Date header (#59080)
* Mail module : add date header (#58808)
This commit is contained in:
parent
de66abe521
commit
f0eaf1fb39
2 changed files with 4 additions and 1 deletions
2
changelogs/fragments/58808-mail-add-date-header.yaml
Normal file
2
changelogs/fragments/58808-mail-add-date-header.yaml
Normal 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).
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Reference in a new issue