mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
(cherry picked from commit 750d96a95f
)
Co-authored-by: Lénaïc Huard <L3n41c@users.noreply.github.com>
This commit is contained in:
parent
b97ce10156
commit
f78993ba12
2 changed files with 6 additions and 1 deletions
2
changelogs/fragments/4056-add-missing-mail-headers.yml
Normal file
2
changelogs/fragments/4056-add-missing-mail-headers.yml
Normal 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).
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue