
    X2i                        d dl Z d dlZd dlmZ d dlmZmZ d dlmZ  e              e j	        dd          Z
 e e j	        dd                    Z e j	        d	d
          Z e j	        dd
          Z e j	        depd          Z e j	        dd          Z e j	        dd                                          dv Z e j	        dd                                          dv Z e e j	        dd                    Z e j	        dd                                          dv Zddedee         dee         dee         def
dZddedee         dee         dee         ddf
dZdS )     N)EmailMessage)OptionalSequence)load_dotenv	SMTP_HOSTzsmtp.gmail.com	SMTP_PORT587	SMTP_USER 	SMTP_PASS	SMTP_FROMzno-reply@example.comSMTP_FROM_NAMENbitzSMTP_USE_TLStrue>   1onyesr   SMTP_USE_SSLfalseSMTP_TIMEOUT30
SMTP_DEBUGsubjecttohtmltextreturnc                    t                      }t          rt           dt           dnt          }||d<   d                    |          |d<   | |d<   |r/|r-|                    |           |                    |d           n\|r-|                    d	           |                    |d           n-|r|                    |           n|                    d
           |S )Nz <>Fromz, ToSubjectr   )subtypezDThis email contains HTML content. Please use an HTML-capable client.r   )r   r   r   joinset_contentadd_alternative)r   r   r   r   msgfrom_displays         +D:\Nbitz\nbitez_python\app\utility\email.py_build_messager+      s    
..C8FUn44	4444ILCK		"CIC	N 
 
D&1111	 ^___D&1111	 J    c                    t           st          d          dt                                           v pdt                                           v }|r`t          rt          st          d          t
                                          t                                          k    rt          d          t          | |||          }t          rt          j	        t           t          t                    5 }t          r|                    d           t          r't          r |                    t          t                     |                    |           	 d d d            d S # 1 swxY w Y   t          j        t           t          t                    5 }t          r|                    d           |                                 t$          r(|                                 |                                 t          r't          r |                    t          t                     |                    |           d d d            d S # 1 swxY w Y   d S )	NzSMTP_HOST is not configuredgmailgooglezSMTP_USER/SMTP_PASS not configured. For Gmail, set SMTP_USER to your Gmail address and SMTP_PASS to a Gmail App Password (not your normal password).zXFor Gmail SMTP, SMTP_FROM must match SMTP_USER. Set SMTP_FROM to the same Gmail address.)r   r   )timeout   )r   RuntimeErrorlowerr
   r   r   r+   r   smtplibSMTP_SSLr   r   r   set_debuglevelloginsend_messageSMTPehlor   starttls)r   r   r   r   is_gmailr(   servers          r*   
send_emailr>   +   s    :8999 )//+++Lx9??;L;L/LH 	 		 	\   ??	 1 111j   "4d
;
;
;C iLIII 	V )%%a((( 3Y 3Y	222$$$	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 
iL	A	A	A 	!V 	%!!!$$$ 	OOKKMMM 	/ 	/LLI...C   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s&   /A!EE!$E!B#H>>II)NN)osr4   email.messager   typingr   r   dotenvr   getenvr   intr   r
   r   r   r   r3   r   r   r   r   strr+   r>    r,   r*   <module>rG      s   				  & & & & & & % % % % % % % %       BIk#344	C		+u--..	BIk2&&	BIk2&&	BIk9#F0FGG	+W55ry006688<VVry117799=WWs929^T2233RY|W--33559SS
 C Xc] (3- V^_bVc o{    (%! %! %!# %!hsm %!RZ[^R_ %!ko %! %! %! %! %! %!r,   