a
    g]f	                     @   s@   d dl Z d dlmZ d dlmZ d dlZd dlmZ dd ZdS )    N)MIMEMultipart)MIMEText)Environmentc                 C   s   t j}t j}t j}t j}t }t j|d< | |d< d|d< dj||d}|t|dd t	
 }	tj|||	d	t}
|
|| z$|
|d |d | d W n2 ty } ztd
|  W Y d}~n
d}~0 0 W d   n1 s0    Y  dS )a  
    Sends a customized email to a specified recipient with a verification link.

    This function constructs and sends an HTML email to the given recipient's email address. 

    Parameters:
    - recipient_email (str): The email address of the recipient to whom the email will be sent.
    - user_name (str): The name of the recipient to be used in the email's greeting.
    - verification_link (str): The URL that the recipient must visit to verify their email address.

    FromTozVerify your email for StoryItSubjectu  
    <html>
        <body>
            <p>Hello {user_name},</p>
            <br/>
            <p>Follow this link to verify your email address.</p>

            <a href="{verification_link}">Verify Email</a>

            <br/>
            <p>If you didn’t ask to verify this address, you can ignore this email.</p>
            
            <p>Thanks,</p>
            <p>Your StoryIt team</p>
            <a href="https://www.storyit.app/">
            <img src="https://storage.googleapis.com/storyitapp-dev.appspot.com/storyIt_logo/logo_storyit.png" alt="StroyIt" style="width: 150px;">
            </a>
        </body>
    </html>
    )	user_nameverification_linkhtmlzutf-8)contextzFailed to send email: N)r   SMTP_SERVER	SMTP_PORTSMTP_USERNAMESMTP_PASSWORDr   formatattachr   sslcreate_default_contextsmtplibSMTP_SSLloginsendmail	as_stringencodeUnicodeEncodeErrorprint)Zrecipient_emailr   r	   Zsmtp_serverZ	smtp_portZsmtp_usernameZsmtp_passwordmsgbodyr   servere r    4C:\storyit\storyit_web\backend\services\send_mail.pysend_custom_email	   s*    
r"   )	r   email.mime.multipartr   email.mime.textr   r   environmentr   r"   r    r    r    r!   <module>   s
   