summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan <jdelannoye@gmail.com>2019-07-16 16:56:00 +0200
committerBrian Coca <bcoca@users.noreply.github.com>2019-07-16 10:55:59 -0400
commitf0eaf1fb397e0123852e2c87bca9f3809b1ed167 (patch)
tree818b6e89c9f8537a0434f597abf4978a9ecb9f1f
parentde66abe52182bc124ffbd0ef0559375d471c79fe (diff)
downloadansible-f0eaf1fb397e0123852e2c87bca9f3809b1ed167.tar.gz
Module mail : Add Date header (#59080)
* Mail module : add date header (#58808)
-rw-r--r--changelogs/fragments/58808-mail-add-date-header.yaml2
-rw-r--r--lib/ansible/modules/notification/mail.py3
2 files changed, 4 insertions, 1 deletions
diff --git a/changelogs/fragments/58808-mail-add-date-header.yaml b/changelogs/fragments/58808-mail-add-date-header.yaml
new file mode 100644
index 0000000000..a797e369cc
--- /dev/null
+++ b/changelogs/fragments/58808-mail-add-date-header.yaml
@@ -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).
diff --git a/lib/ansible/modules/notification/mail.py b/lib/ansible/modules/notification/mail.py
index 057f826bf6..bae57ff274 100644
--- a/lib/ansible/modules/notification/mail.py
+++ b/lib/ansible/modules/notification/mail.py
@@ -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"