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:
parent
4a1006ac34
commit
671b7ab149
2 changed files with 8 additions and 1 deletions
|
@ -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).
|
|
@ -222,7 +222,7 @@ import smtplib
|
||||||
import ssl
|
import ssl
|
||||||
import traceback
|
import traceback
|
||||||
from email import encoders
|
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.base import MIMEBase
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
|
@ -349,6 +349,11 @@ def main():
|
||||||
msg['From'] = formataddr((sender_phrase, sender_addr))
|
msg['From'] = formataddr((sender_phrase, sender_addr))
|
||||||
msg['Date'] = formatdate(localtime=True)
|
msg['Date'] = formatdate(localtime=True)
|
||||||
msg['Subject'] = Header(subject, charset)
|
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"
|
msg.preamble = "Multipart message"
|
||||||
|
|
||||||
for header in headers:
|
for header in headers:
|
||||||
|
|
Loading…
Reference in a new issue