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)

This commit is contained in:
Lénaïc Huard 2022-01-21 07:27:20 +01:00 committed by GitHub
parent c7500c217f
commit 750d96a95f
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 os
import re
import email.utils
import smtplib
from ansible.module_utils.six import string_types
@ -100,10 +101,12 @@ class CallbackModule(CallbackBase):
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
if 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 += body