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