o
    /xh~
                     @   s<   d dl Z d dlmZ d dlmZ d dlmZmZ dd ZdS )    N)MIMEText)MIMEMultipart)current_apprender_templatec              
   C   s  zt d t d|  t dtjd  t dtjd  t dtjd  t }tjd |d	< | |d
< | d|d< d| d}|t|d t d ttjd ttjd 6}|	d |
  t d |tjd tjd  t d|  d ||d	 |d
 |  W d    n1 sw   Y  t d dddW S  ty } zt d| ddt| dW  Y d }~S d }~ww )Nu   🔧 Email sending triggered...zTo:zUsing SMTP Host:
EMAIL_HOSTzPort:
EMAIL_PORTzFrom:
EMAIL_USERZFromZToz Email Verification | VRVIDYAZSubjectzd
        <h2>VRVIDYA Email Verification</h2>
        <p>Your OTP for email verification is: <strong>zW</strong></p>
        <p>Please use this OTP to verify your email address.</p>
        htmlu!   📨 Connecting to SMTP server...   u   🔐 Logging in to SMTP...EMAIL_PASSWORDu   📤 Sending email to z...u   ✅ Email successfully sent!TzEmail sent successfully)statusmessageu   ❌ Email sending failed:FzFailed to send email: )printr   configr   attachr   smtplibZSMTPintset_debuglevelZstarttlsloginZsendmail	as_string	Exceptionstr)to_emailotp	user_typemsgZhtml_contentservere r   QD:\Internship2\StudyBuddy\EduRuby_flask\flask_backend-main\utils\email_service.py
send_email   s<   


 r    )	r   Zemail.mime.textr   Zemail.mime.multipartr   flaskr   r   r    r   r   r   r   <module>   s
    