Commit 18eca152 by Daniel Hokka Zakrisson

Merge pull request #2130 from lessmian/devel

mail module: properly set charset
parents cc159a68 a124a7f6
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment