HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/breezy/__pycache__/smtp_connection.cpython-39.pyc
a

�*�^��@sdZddlmZzddlmZmZWn"eyFddlmZmZYn0ddlZddl	Z	ddl
Z
ddlmZm
Z
ddlmZmZejddd	d
�Zejdddd
�Zejd
ddd
�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)z#A convenience class around smtplib.�)�absolute_import)�getaddresses�	parseaddrN�)�config�osutils)�BzrError�InternalBzrError�
smtp_passwordz3Password to use for authentication to SMTP server.
)�default�help�smtp_serverz6Hostname of the SMTP server to use for sending email.
�
smtp_usernamez3Username to use for authentication to SMTP server.
c@seZdZdZdd�ZdS)�	SMTPErrorzSMTP error: %(error)scCs
||_dS�N)�error)�selfr�r�8/usr/lib/python3/dist-packages/breezy/smtp_connection.py�__init__:szSMTPError.__init__N��__name__�
__module__�__qualname__�_fmtrrrrrr6src@seZdZdZdd�ZdS)�SMTPConnectionRefusedz#SMTP connection to %(host)s refusedcCs||_||_dSr)r�host)rrrrrrrBszSMTPConnectionRefused.__init__Nrrrrrr>src@seZdZdZdS)�DefaultSMTPConnectionRefusedz;Please specify smtp_server.  No server at default %(host)s.N�rrrrrrrrrGsrc@seZdZdZdS)�NoDestinationAddressz,Message does not have a destination address.NrrrrrrLsrc@sJeZdZdZdZddd�Zdd�Zdd	�Zd
d�Ze	dd
��Z
dd�ZdS)�SMTPConnectionz�Connect to an SMTP server and send an email.

    This is a gateway between breezy.config.Config and smtplib.SMTP. It
    understands the basic bzr SMTP configuration information: smtp_server,
    smtp_username, and smtp_password.
    Z	localhostNcCsf||_|jdurtj|_||_|�d�|_|j|_|jdurD|j|_|�d�|_|�d�|_	d|_
dS)Nr
rr
)�
_smtp_factory�smtplibZSMTPZ_config�get�_config_smtp_server�_smtp_server�_default_smtp_server�_smtp_username�_smtp_password�_connection)rrr!rrrr[s

zSMTPConnection.__init__cCs"|jdurdS|��|��dS)z2If we haven't connected, connect and authenticate.N)r)�_create_connection�
_authenticate)rrrr�_connectjs
zSMTPConnection._connectc
CsZ|��|_z|j�|j�Wnbtjy~}zH|jdtjkrh|j	durXt
tj|j��qjttj|j��n�WYd}~n
d}~00|j��\}}d|kr�dks�n|j�
�\}}d|kr�dks�ntd||f��|j�d��rV|j��\}}d|k�rdk�sntd||f��|j��\}}d|k�rDdk�sVntd||f��dS)	zCreate an SMTP connection.rN��i+zserver refused HELO: %d %s�starttlszserver refused STARTTLS: %d %szserver refused EHLO: %d %s)r!r)Zconnectr%�socketr�args�errnoZECONNREFUSEDr$rrZehloZhelorZhas_extnr.)r�e�codeZresprrrr*us6

���z!SMTPConnection._create_connectioncCsxt��}|jdur0|�d|j�|_|jdur0dS|jdurN|�d|j|j�|_t�|j�}t�|j�}|j	�
||�dS)z1If necessary authenticate yourself to the server.NZsmtp)rZAuthenticationConfigr'Zget_userr%r(Zget_passwordrZ	safe_utf8r)Zlogin)rZauthZusernameZpasswordrrrr+�s



�zSMTPConnection._authenticatecCsVt|�dd��d}g}dD]}|�|d�}|r|�|�qdd�t|�D�}||fS)a�Get the origin and destination addresses of a message.

        :param message: A message object supporting get() to access its
            headers, like email.message.Message or
            breezy.email_message.EmailMessage.
        :return: A pair (from_email, to_emails), where from_email is the email
            address in the From header, and to_emails a list of all the
            addresses in the To, Cc, and Bcc headers.
        ZFromNr)ZToZCcZBcccSsg|]}|d�qS)rr)�.0Zpairrrr�
<listcomp>��z8SMTPConnection.get_message_addresses.<locals>.<listcomp>)rr#�appendr)�message�
from_emailZto_full_addresses�header�value�	to_emailsrrr�get_message_addresses�s�z$SMTPConnection.get_message_addressesc
Cs�|�|�\}}|st�z |��|j�|||���Wn�tjyv}z&tdt	t
|j������WYd}~nrd}~0tj
y�}z td|j|jf��WYd}~n:d}~0tjy�}ztt|���WYd}~n
d}~00dS)z�Send an email message.

        The message will be sent to all addresses in the To, Cc and Bcc
        headers.

        :param message: An email.message.Message or
            email.mime.multipart.MIMEMultipart object.
        :return: None
        zserver refused recipient: %d %sNz%d %s)r=rr,r)ZsendmailZ	as_stringr"ZSMTPRecipientsRefusedr�next�iterZ
recipients�valuesZSMTPResponseExceptionZ	smtp_codeZ
smtp_errorZ
SMTPException�str)rr8r9r<r2rrr�
send_email�s 

��(zSMTPConnection.send_email)N)rrr�__doc__r&rr,r*r+�staticmethodr=rBrrrrr Qs
"
r )rCZ
__future__rZemail.utilsrr�ImportErrorZemail.Utilsr1r"r/�rr�errorsrr	ZOptionr
r
rrrrr�objectr rrrr�<module>s0���