o
    gm                     @   sX   d dl Z d dlmZ d dlmZ d dlZd dlmZ edZ	de
de
defd	d
ZdS )    N)MIMEMultipart)MIMEText)settings	adimsayar	recipientverification_codereturnc              
   C   s  zot j}t j}t j}t j}t j}t j}td}d|d< ||d< | |d< d| }	d| d}
t|	d	}t|
d
}|	| |	| t
||}| dkrR|  ||| ||| |  |  td|   W dS  ty } ztjdt| dd W Y d}~dS d}~ww )z
    Send an email with the verification code using SMTP.
    The settings should configure:
      - MAIL_FROM_ADDRESS, MAIL_HOST, MAIL_PORT, MAIL_USERNAME,
        MAIL_PASSWORD, and MAIL_ENCRYPTION.
    alternativezYour Verification CodeSubjectFromTozYour verification code is: zY
        <html>
            <body>
                <p>Your verification code is: <strong>z:</strong></p>
            </body>
        </html>
        plainhtmltlszVerification email sent to Tz"Error sending verification email: )exc_infoNF)r   MAIL_FROM_ADDRESS	MAIL_HOST	MAIL_PORTMAIL_USERNAMEMAIL_PASSWORDMAIL_ENCRYPTIONr   r   attachsmtplibSMTPlowerstarttlsloginZsendmail	as_stringquitloggerinfo	Exceptionerrorstr)r   r   senderZ	mail_hostZ	mail_portZmail_usernameZmail_passwordZmail_encryptionmessagetextr   Zpart1Zpart2servere r)   O/Users/jin/Developments/work/ea/adimsayer_backend/app/services/email_service.pysend_verification_email	   s@   




r+   )r   Zemail.mime.multipartr   Zemail.mime.textr   loggingapp.core.configr   	getLoggerr   r#   boolr+   r)   r)   r)   r*   <module>   s    
