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

mail module: add Message-ID header (#7740)

* mail module: add Message-ID header

* Update plugins/modules/mail.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Sébastien Bocahu 2023-12-27 11:19:17 +01:00 committed by GitHub
parent 4a1006ac34
commit 671b7ab149
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- mail - add ``Message-ID`` header; which is required by some mail servers (https://github.com/ansible-collections/community.general/pull/7740).

View file

@ -222,7 +222,7 @@ import smtplib
import ssl
import traceback
from email import encoders
from email.utils import parseaddr, formataddr, formatdate
from email.utils import parseaddr, formataddr, formatdate, make_msgid
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@ -349,6 +349,11 @@ def main():
msg['From'] = formataddr((sender_phrase, sender_addr))
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = Header(subject, charset)
try:
msg['Message-ID'] = make_msgid(domain='ansible')
except TypeError:
# `domain` is only available in Python 3
msg['Message-ID'] = make_msgid()
msg.preamble = "Multipart message"
for header in headers: