HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/smtp.cpython-310.pyc
o

�N�g#
�@sfdZddlZddlZddlZddlmZzddlZdZWney'dZYnwe�	e
�Zdd�ZdS)a�
Return salt data via email

The following fields can be set in the minion conf file:

    smtp.from (required)
    smtp.to (required)
    smtp.host (required)
    smtp.port (optional, defaults to 25)
    smtp.username (optional)
    smtp.password (optional)
    smtp.tls (optional, defaults to False)
    smtp.subject (optional, but helpful)
    smtp.gpgowne' (optional)
    smtp.fields (optional)
    smtp.content (optional)

There are a few things to keep in mind:

* If a username is used, a password is also required. It is recommended (but
  not required) to use the TLS setting when authenticating.
* You should at least declare a subject, but you don't have to.
* The use of encryption, i.e. setting gpgowner in your settings, requires
  python-gnupg to be installed.
* The field gpgowner specifies a user's ~/.gpg directory. This must contain a
  gpg public key matching the address the mail is sent to. If left unset, no
  encryption will be used.
�N)�
formatdateTFc	Cs�d}i}|D]
}|�|d�||<q|�|�|dsd|d<t�d|d�t�d|d�trm|drmtjtj�	d	�
|d��d
gd�}|�|d|d
�}|jr^t�d�t
|�|d<nt�d�d�
|j|j�|d<d�
|d|d
tdd�|d|d�}t�d�t�|dt|d��}|ddur�|��t�d�|dr�|dr�|�|d|d�t�d�|�|d|d
|�t�d�|��dS)z%
    Send an email with the data
    )
�smtp.to�	smtp.from�	smtp.host�	smtp.port�smtp.tls�
smtp.username�
smtp.password�smtp.subject�
smtp.gpgowner�smtp.content�r�zSMTP port has been set to %szsmtp_return: Subject is '%s'r
rz
~{}/.gnupgz--trust-model always)Z	gnupghome�optionsrrz"smtp_return: Encryption successfulz;SMTP: Encryption failed, only an error message will be sentz:Encryption failed, the return data was not sent.

{}
{}z-From: {}
To: {}
Date: {}
Subject: {}

{}rT)�	localtimez(smtp_return: Connecting to the server...rrzsmtp_return: TLS enabledrr	zsmtp_return: Authenticatedzsmtp_return: Message sent.N)�get�update�log�debug�	HAS_GNUPG�gnupgZGPG�os�path�
expanduser�formatZencrypt�ok�str�error�status�stderrr�smtplibZSMTP�intZstarttlsZloginZsendmail�quit)	�kwargs�optsZopt_keysZconfig�keyZgpgZencrypted_data�messageZserver�r'�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/smtp.py�send.sR

�

���



r))
�__doc__�loggingrr �email.utilsrrr�ImportError�	getLogger�__name__rr)r'r'r'r(�<module>s�