mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
mail module: properly set charset
This commit is contained in:
parent
1b73227a30
commit
e8254dee4d
1 changed files with 9 additions and 1 deletions
10
library/mail
10
library/mail
|
@ -94,6 +94,11 @@ options:
|
|||
default: null
|
||||
required: false
|
||||
version_added: "1.0"
|
||||
charset:
|
||||
description:
|
||||
- The character set of email being sent
|
||||
default: 'us-ascii'
|
||||
requred: false
|
||||
examples:
|
||||
- description: "Example playbook sending mail to root"
|
||||
code: "local_action: mail msg='System ${ansible_hostname} has been sucessfully provisioned.'"
|
||||
|
@ -109,6 +114,7 @@ examples:
|
|||
cc="Charlie Root <root@localhost>"
|
||||
attach="/etc/group /tmp/pavatar2.png"
|
||||
headers=Reply-To=john@example.com|X-Special="Something or other"
|
||||
charset=utf8
|
||||
"""
|
||||
|
||||
import os
|
||||
|
@ -144,6 +150,7 @@ def main():
|
|||
body = dict(default=None),
|
||||
attach = dict(default=None),
|
||||
headers = dict(default=None),
|
||||
charset = dict(default='us-ascii')
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -157,6 +164,7 @@ def main():
|
|||
body = module.params.get('body')
|
||||
attach_files = module.params.get('attach')
|
||||
headers = module.params.get('headers')
|
||||
charset = module.params.get('charset')
|
||||
|
||||
sender_phrase, sender_addr = parseaddr(sender)
|
||||
|
||||
|
@ -206,7 +214,7 @@ def main():
|
|||
if len(cc_list) > 0:
|
||||
msg['Cc'] = ", ".join(cc_list)
|
||||
|
||||
part = MIMEText(body + "\n\n")
|
||||
part = MIMEText(body + "\n\n", _charset=charset)
|
||||
msg.attach(part)
|
||||
|
||||
if attach_files is not None:
|
||||
|
|
Loading…
Reference in a new issue