Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/notification/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/notification/mail.pyc

�
�Udac@`s;ddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	dd
l
Z
dd
lZdd
lZddl
mZddlmZmZmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlm Z d�Z!e"dkr7e!�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontstableinterfacetstatust	communitytsupported_bys�
---
author:
- Dag Wieers (@dagwieers)
module: mail
short_description: Send an email
description:
- This module is useful for sending emails from playbooks.
- One may wonder why automate sending emails?  In complex environments
  there are from time to time processes that cannot be automated, either
  because you lack the authority to make it so, or because not everyone
  agrees to a common approach.
- If you cannot automate a specific step, but the step is non-blocking,
  sending out an email to the responsible party to make them perform their
  part of the bargain is an elegant way to put the responsibility in
  someone else's lap.
- Of course sending out a mail can be equally useful as a way to notify
  one or more people in a team that a specific action has been
  (successfully) taken.
version_added: '0.8'
options:
  from:
    description:
    - The email-address the mail is sent from. May contain address and phrase.
    type: str
    default: root
  to:
    description:
    - The email-address(es) the mail is being sent to.
    - This is a list, which may contain address and phrase portions.
    type: list
    default: root
    aliases: [ recipients ]
  cc:
    description:
    - The email-address(es) the mail is being copied to.
    - This is a list, which may contain address and phrase portions.
    type: list
  bcc:
    description:
    - The email-address(es) the mail is being 'blind' copied to.
    - This is a list, which may contain address and phrase portions.
    type: list
  subject:
    description:
    - The subject of the email being sent.
    required: yes
    type: str
  body:
    description:
    - The body of the email being sent.
    type: str
    default: $subject
  username:
    description:
    - If SMTP requires username.
    type: str
    version_added: '1.9'
  password:
    description:
    - If SMTP requires password.
    type: str
    version_added: '1.9'
  host:
    description:
    - The mail server.
    type: str
    default: localhost
  port:
    description:
    - The mail server port.
    - This must be a valid integer between 1 and 65534
    type: int
    default: 25
    version_added: '1.0'
  attach:
    description:
    - A list of pathnames of files to attach to the message.
    - Attached files will have their content-type set to C(application/octet-stream).
    type: list
    default: []
    version_added: '1.0'
  headers:
    description:
    - A list of headers which should be added to the message.
    - Each individual header is specified as C(header=value) (see example below).
    type: list
    default: []
    version_added: '1.0'
  charset:
    description:
    - The character set of email being sent.
    type: str
    default: utf-8
  subtype:
    description:
    - The minor mime type, can be either C(plain) or C(html).
    - The major type is always C(text).
    type: str
    choices: [ html, plain ]
    default: plain
    version_added: '2.0'
  secure:
    description:
    - If C(always), the connection will only send email if the connection is Encrypted.
      If the server doesn't accept the encrypted connection it will fail.
    - If C(try), the connection will attempt to setup a secure SSL/TLS session, before trying to send.
    - If C(never), the connection will not attempt to setup a secure SSL/TLS session, before sending
    - If C(starttls), the connection will try to upgrade to a secure SSL/TLS connection, before sending.
      If it is unable to do so it will fail.
    type: str
    choices: [ always, never, starttls, try ]
    default: try
    version_added: '2.3'
  timeout:
    description:
    - Sets the timeout in seconds for connection attempts.
    type: int
    default: 20
    version_added: '2.3'
s(
- name: Example playbook sending mail to root
  mail:
    subject: System {{ ansible_hostname }} has been successfully provisioned.
  delegate_to: localhost

- name: Sending an e-mail using Gmail SMTP servers
  mail:
    host: smtp.gmail.com
    port: 587
    username: [email protected]
    password: mysecret
    to: John Smith <[email protected]>
    subject: Ansible-report
    body: System {{ ansible_hostname }} has been successfully provisioned.
  delegate_to: localhost

- name: Send e-mail to a bunch of users, attaching files
  mail:
    host: 127.0.0.1
    port: 2025
    subject: Ansible-report
    body: Hello, this is an e-mail. I hope you like it ;-)
    from: [email protected] (Jane Jolie)
    to:
    - John Doe <[email protected]>
    - Suzie Something <[email protected]>
    cc: Charlie Root <root@localhost>
    attach:
    - /etc/group
    - /tmp/avatar2.png
    headers:
    - [email protected]
    - X-Special="Something or other"
    charset: us-ascii
  delegate_to: localhost

- name: Sending an e-mail using the remote machine, not the Ansible controller node
  mail:
    host: localhost
    port: 25
    to: John Smith <[email protected]>
    subject: Ansible-report
    body: System {{ ansible_hostname }} has been successfully provisioned.

- name: Sending an e-mail using Legacy SSL to the remote machine
  mail:
    host: localhost
    port: 25
    to: John Smith <[email protected]>
    subject: Ansible-report
    body: System {{ ansible_hostname }} has been successfully provisioned.
    secure: always

- name: Sending an e-mail using StartTLS to the remote machine
  mail:
    host: localhost
    port: 25
    to: John Smith <[email protected]>
    subject: Ansible-report
    body: System {{ ansible_hostname }} has been successfully provisioned.
    secure: starttls
N(tencoders(t	parseaddrt
formataddrt
formatdate(tMIMEBase(t
MIMEMultipart(tMIMEText(tHeader(t
AnsibleModule(tPY3(t	to_nativec(*C`stdtdtdd�dtdddt�dtdddd	�d
tdddd�d
tddddddg�dtddddgddg�dtdddg�dtdddg�dtdddtddg�dtdd�dtdddg�dtdddg�dtdddd�dtddddd d!dg�d"tdddd#d d$d%d&d#g�d'tdddd(��d)ddgg�}|jjd�}|jjd�}|jjd�}|jjd
�}|jjd
�}|jjd�}|jjd�}|jjd�}|jjd�}	|jjd�}
|jjd�}|jjd�}|jjd�}
|jjd�}|jjd"�}|jjd'�}d*}t}t|�\}}|
s�|	}
ny5|d%kr�y[tr'tj	d|d
|d'|�}ntj	d'|�}|j
||�\}}t}Wq�tjk
r�}|d$kr�|j
d+d,dd-||t|�fd.tj��q�q�tk
r�q�Xn|s"tr�tjd|d
|d'|�}ntjd'|�}|j
||�\}}nWnKtjk
rp}|j
d+d,dd/||t|�fd.tj��nXy|j�WnKtjk
r�}|j
d+d,dd0||t|�fd.tj��nXt|�d*kr�|r�|dTkr�|jd1�r�y|j�t}WnKtjk
rb}|j
d+d,dd-||t|�fd.tj��nXy|j�Wq�tjk
r�}|j
d+d,dd0||t|�fd.tj��q�Xq�|d&kr�|j
d+d,dd2||f�q�q�n|r�|r�|jd3�r�y|j||�Wq�tjk
r\|j
d+d,dd4||f�q�tjk
r�|j
d+d,dd5||f�q�Xq�|j
d+d,dd6||f�n|r�|r�|r�|jd7�ntd8|
�}t||f�|d9<td:t�|d;<t|	|
�|d<<d=|_x�|D]�}x�g|j d>�D]}|j!�^qMD]i}y>|j d?�\}}tt||
��}|j"||�Wqctk
r�|jd@|�qcXqcWq4WdA|kr�|j"dAdB�ng}x>g|D]}|j!�^qD]}|j#t|�d,�qWg} xWg|D]}|j!�^qJD]6}| j#tt|���|j#t|�d,�q`WdCj$| �|dD<g}!xWg|D]}|j!�^q�D]6}|!j#tt|���|j#t|�d,�q�WdCj$|!�|dE<t%|
dFdG|d8|
�}"|j&|"�x�|D]�}#yzt'dHdI�}"t(|#dJ��}$|"j)|$j*��WdQXt+j,|"�|"j"dKdLdMt-j.j/|#��|j&|"�WqP	tk
r
}|j
d+d,ddN|#t|�fd.tj��qP	XqP	W|j0�}%y|j1|t2|�|%�}&WnTtk
r�
}|j
d+d,ddOdCj$t2|��t|�fd.tj��nX|j3�|&rx8|&D]0}'|jdP|'|&|'d*|&|'d,f�q�
W|j4ddQdR|&�n|j4ddSdR|&�dS(UNt
argument_spectusernamettypetstrtpasswordtno_logthosttdefaultt	localhosttporttintitsendertroottaliasestfromttotlistt
recipientstcctbcctsubjecttrequiredtmsgtbodytattachtheaderstcharsetsutf-8tsubtypetplaintchoicesthtmltsecurettrytalwaystnevertstarttlsttimeoutitrequired_togetheritrcis1Unable to start an encrypted session to %s:%s: %st	exceptionsUnable to Connect %s:%s: %ssHelo failed for host %s:%s: %stSTARTTLSs'StartTLS is not offered on server %s:%stAUTHsJAuthentication to %s:%s failed, please check your username and/or passwords4No Suitable authentication method was found on %s:%ss(No Authentication on the server at %s:%ss1Username and Password was sent without encryptiont_charsettFromt	localtimetDatetSubjectsMultipart messaget|t=s%Skipping header '%s', unable to parsesX-MailersAnsible mail modules, tTotCcs

t_subtypetapplicationsoctet-streamtrbsContent-dispositiont
attachmenttfilenames-Failed to send mail: can't attach file %s: %ssFailed to send mail to '%s': %ss"Failed to send mail to '%s': %s %ss-Failed to send mail to at least one recipienttresultsMail sent successfully(sstarttlsR3(5RtdicttTruetparamstgettFalseR	RtsmtplibtSMTP_SSLtconnecttssltSSLErrort	fail_jsonRt	tracebackt
format_exct	ExceptiontSMTPt
SMTPExceptiontehloRthas_extnR6tlogintSMTPAuthenticationErrortwarnR
R
RRtpreambletsplittstript
add_headertappendtjoinRR+Rtopentset_payloadtreadRt
encode_base64tostpathtbasenamet	as_stringtsendmailtsettquitt	exit_json((tmoduleRRRRRR$tcopiestblindcopiesR'R*tattach_filesR,R-R.R2R7tcodetsecure_statet
sender_phrasetsender_addrtsmtptsmtpmessageteR)theadertxthdrth_keyth_valt	addr_listtaddrtto_listtcc_listtpartRJtfptcomposedRKtkey((sE/usr/lib/python2.7/site-packages/ansible/modules/notification/mail.pytmain�s !!'	!
)
!99

'<)#'#	
/
&&&


"(3

.t__main__(#t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESRkRQRTRWtemailRtemail.utilsR	R
Rtemail.mime.baseRtemail.mime.multipartR
temail.mime.textRtemail.headerRtansible.module_utils.basicRtansible.module_utils.sixRtansible.module_utils._textRR�t__name__(((sE/usr/lib/python2.7/site-packages/ansible/modules/notification/mail.pyt<module>s,


z@	�

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]