1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

mail: add Date and Message-ID headers (#4056) (#4069)

(cherry picked from commit 750d96a95f)

Co-authored-by: Lénaïc Huard <L3n41c@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2022-01-21 09:29:15 +01:00 committed by GitHub
parent b97ce10156
commit f78993ba12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- mail callback plugin - add ``Message-ID`` and ``Date`` headers (https://github.com/ansible-collections/community.general/issues/4055, https://github.com/ansible-collections/community.general/pull/4056).

View file

@ -59,6 +59,7 @@ notes:
import json import json
import os import os
import re import re
import email.utils
import smtplib import smtplib
from ansible.module_utils.six import string_types from ansible.module_utils.six import string_types
@ -100,10 +101,12 @@ class CallbackModule(CallbackBase):
smtp = smtplib.SMTP(self.smtphost, port=self.smtpport) smtp = smtplib.SMTP(self.smtphost, port=self.smtpport)
content = 'From: %s\n' % self.sender content = 'Date: %s\n' % email.utils.formatdate()
content += 'From: %s\n' % self.sender
content += 'To: %s\n' % self.to content += 'To: %s\n' % self.to
if self.cc: if self.cc:
content += 'Cc: %s\n' % self.cc content += 'Cc: %s\n' % self.cc
content += 'Message-ID: %s\n' % email.utils.make_msgid()
content += 'Subject: %s\n\n' % subject.strip() content += 'Subject: %s\n\n' % subject.strip()
content += body content += body