
    h]v                        S r SSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJr  SSKJrJrJrJr  SSKrSSKrSSKrSS	KJrJrJrJrJrJrJrJr  \R<                  " \5      r  " S
 S5      r!\!" 5       r"    S#S\#S\#S\\\#\4      S\\$   S\\\#\#4      S\\\#      S\%4S jjr&   S$S\#S\#S\#S\\'   S\\   S\\   S\%4S jjr( S%S\#S\#S\#S\\\#\4      S\%4
S jjr)S\#S\#S \S\%4S! jr*S\%4S" jr+g)&z
Email notification service for critical errors and system failures.
This module provides automatic email notifications when critical errors occur.
    N)MIMEText)MIMEMultipart)MIMEBase)encoders)datetime)DictAnyOptionalList)EMAIL_SMTP_SERVEREMAIL_SMTP_PORTEMAIL_USERNAMEEMAIL_PASSWORDEMAIL_RECIPIENTSEMAIL_FROM_ADDRESSEMAIL_USE_TLSEMAIL_USE_SSLc                   0   \ rS rSrSrS rS r    S(S\S\S\\	\\
4      S	\\   S
\\	\\4      S\\\      S\4S jjr   S)S\S\S\S\\   S\\	   S\\	   S\4S jjr S*S\S\S\S\\	\\
4      S\4
S jjr   S)S\S\S\\	\\
4      S	\\   S
\\	\\4      S\4S jjr   S)S\S\S\S\\   S\\	   S\\	   S\4S jjr S+S\S\S\S\\	\\
4      S\4
S jjrS,S\S\S\S\\   S\4
S jjrS\S \S!\S\4S" jrS\S#\S$\S\4S% jrS\4S& jrS'rg)-EmailNotifier   z@Email notification service for critical errors and system alertsc                     [         U l        [        U l        [        U l        [        U l        [        U l	        [        U l        [        U l        [        U l        U R!                  5         g)z5Initialize the email notifier with SMTP configurationN)r   smtp_serverr   	smtp_portr   usernamer   passwordr   
recipientsr   from_addressr   use_tlsr   use_ssl_validate_config)selfs    8D:\Projects\AI-TestCaseGenerator\utils\email_notifier.py__init__EmailNotifier.__init__   sJ    ,(&&*.$$ 	    c                    SU R                   4SU R                  4SU R                  4SU R                  4SU R                  4SU R
                  4/n/ nU H  u  p4U(       a  M  UR                  U5        M!     U(       a/  [        R                  SSR                  U5       35        S	U l
        gS
U l
        [        R                  S5        g)zValidate email configurationSMTP_SERVER	SMTP_PORTUSERNAMEPASSWORD
RECIPIENTSFROM_ADDRESSz5Email notification disabled - missing configuration: , FTz3Email notification service initialized successfullyN)r   r   r   r   r   r   appendloggerwarningjoinenabledinfo)r!   required_configsmissing_configsnamevalues        r"   r    EmailNotifier._validate_config*   s     D,,-$..)''4??+T../
 +KD5&&t, , NNRSWS\S\]lSmRnop DLDLKKMNr%   N
error_typeerror_messagecontext	exceptionuser_contextr   returnc                    U R                   (       d  [        R                  S5        g SU S3nU R                  XX4U5      nU R	                  XxSUS9$ ! [
         a+  n	[        R                  S[        U	5       35         Sn	A	gSn	A	ff = f)	a[  
Send critical error notification email

Args:
    error_type: Type of error (API_FAILURE, SYSTEM_ERROR, etc.)
    error_message: Error message
    context: Additional context data
    exception: Exception object if available
    user_context: User information if available
    
Returns:
    bool: True if email sent successfully, False otherwise
zCEmail notifications disabled - skipping critical error notificationFu   🚨 CRITICAL ERROR ALERT -  - AI Test Case GeneratorTis_htmlr   z,Failed to send critical error notification: N)r2   r/   r0   _create_error_email_body_send_email	Exceptionerrorstr)
r!   r9   r:   r;   r<   r=   r   subjectbodyes
             r"    send_critical_error_notification.EmailNotifier.send_critical_error_notificationA   s    $ ||NN`a	4ZL@YZG 007|D
 ##G4J#WW 	LLGAxPQ	s   )A 
B!BBapi_nameendpointstatus_coderesponse_datarequest_datac                    U R                   (       d  [        R                  S5        g SU S3nU R                  XX4XV5      nU R	                  XxSS9$ ! [
         a+  n	[        R                  S[        U	5       35         Sn	A	gSn	A	ff = f)	a  
Send API failure notification email

Args:
    api_name: Name of the API (OpenAI, Jira, Azure, etc.)
    endpoint: API endpoint that failed
    error_message: Error message
    status_code: HTTP status code if available
    response_data: API response data if available
    request_data: Request data if available
    
Returns:
    bool: True if email sent successfully, False otherwise
z@Email notifications disabled - skipping API failure notificationFu   ⚠️ API FAILURE - r@   TrB   z)Failed to send API failure notification: N)r2   r/   r0   _create_api_failure_email_bodyrD   rE   rF   rG   )
r!   rM   rN   r:   rO   rP   rQ   rH   rI   rJ   s
             r"   send_api_failure_notification+EmailNotifier.send_api_failure_notificationf   s    $ ||NN]^	-hZ7PQG 66MD
 ##G4#@@ 	LLDSVHMN	s   (A 
B!BB
alert_typemessageseverityc                 :   U R                   (       d  [        R                  S5        g US:X  a  SO	US:X  a  SOSnU SU S	3nU R                  XX45      nU R	                  XgS
S9$ ! [
         a+  n[        R                  S[        U5       35         SnAgSnAff = f)a#  
Send system alert notification

Args:
    alert_type: Type of alert (PERFORMANCE, SECURITY, etc.)
    message: Alert message
    severity: Alert severity (INFO, WARNING, CRITICAL)
    context: Additional context data
    
Returns:
    bool: True if email sent successfully, False otherwise
z4Email notifications disabled - skipping system alertFCRITICAL   🔴WARNING   🟡   🔵z SYSTEM ALERT - r@   TrS   zFailed to send system alert: N)r2   r/   r0   _create_system_alert_email_bodyrD   rE   rF   rG   )	r!   rW   rX   rY   r;   emojirH   rI   rJ   s	            r"   send_system_alertEmailNotifier.send_system_alert   s     ||NNQR	&*4FHPYDY&_eE/
|;TUG 77
X_D ##G4#@@ 	LL8QAB	s   ;A% %
B/!BBc                    [         R                  " 5       R                  S5      nSnU(       a:   SR                  [        R
                  " [        U5      XDR                  5      5      nSnU(       a  S[        R                  " USS9 S3nSn	U(       a?  SSR                  UR                  5        V
Vs/ s H  u  pS	U
 S
U S3PM     snn
5       S3n	SnU(       a  SU S3nSU SU SU SU	 SU SU S3nU$ !   Sn N= fs  snn
f )z*Create HTML email body for critical errors%Y-%m-%d %H:%M:%S UTC zUnable to extract traceback   
            <h3>📋 Additional Context:</h3>
            <pre style="background-color: #f5f5f5; padding: 10px; border-radius: 5px; overflow-x: auto;">   indent</pre>
            uN   
            <h3>👤 User Information:</h3>
            <ul>
                z<li><strong>z:</strong> z</li>z
            </ul>
            u   
            <h3>🔍 Stack Trace:</h3>
            <pre style="background-color: #f5f5f5; padding: 10px; border-radius: 5px; overflow-x: auto; font-size: 12px;">u  
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="UTF-8">
            <title>Critical Error Alert</title>
        </head>
        <body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
            <div style="max-width: 800px; margin: 0 auto; padding: 20px;">
                <div style="background-color: #dc3545; color: white; padding: 20px; border-radius: 10px; margin-bottom: 20px;">
                    <h1 style="margin: 0; font-size: 24px;">🚨 CRITICAL ERROR ALERT</h1>
                    <p style="margin: 10px 0 0 0; font-size: 16px;">AI Test Case Generator System</p>
                </div>
                
                <div style="background-color: #f8f9fa; padding: 20px; border-radius: 10px; margin-bottom: 20px;">
                    <h2 style="color: #dc3545; margin-top: 0;">Error Details</h2>
                    <p><strong>⏰ Timestamp:</strong> u>   </p>
                    <p><strong>🔧 Error Type:</strong> u  </p>
                    <p><strong>📝 Error Message:</strong></p>
                    <div style="background-color: #fff; padding: 15px; border-left: 4px solid #dc3545; margin: 10px 0;">
                        <code style="color: #dc3545; font-size: 14px;">[</code>
                    </div>
                </div>
                
                
                u  
                
                <div style="background-color: #e9ecef; padding: 15px; border-radius: 5px; margin-top: 20px;">
                    <h3>🔧 Recommended Actions:</h3>
                    <ul>
                        <li>Check the application logs for more details</li>
                        <li>Verify system resources and connectivity</li>
                        <li>Review recent deployments or configuration changes</li>
                        <li>Monitor system performance and user impact</li>
                    </ul>
                </div>
                
                <div style="text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid #dee2e6;">
                    <p style="color: #6c757d; font-size: 12px;">
                        This is an automated alert from the AI Test Case Generator monitoring system.
                    </p>
                </div>
            </div>
        </body>
        </html>
        )r   nowstrftimer1   	tracebackformat_exceptiontype__traceback__jsondumpsitems)r!   r9   r:   r;   r<   r=   	timestamptraceback_infocontext_html	user_htmlkvtraceback_html	html_bodys                 r"   rC   &EmailNotifier._create_error_email_body   s    LLN++,CD	 ?!#)C)COY0G0G* "  jjnjtjtu|  FG  kH  jI IL 	 LL^L^L`aL`DAL;qc?L`abc dI "{ |J  {K KN
8  9B{ C::D FH IV W     !	5.	` [?!>  bs   9C8 2D8C>c                     [         R                  " 5       R                  S5      nSnU(       a  S[        R                  " USS9 S3nSn	U(       a  S[        R                  " USS9 S3n	SU S	U S
U SU(       a  SU S3OS SU SU	 SU S3n
U
$ )z'Create HTML email body for API failuresre   rf   u   
            <h3>📤 API Response:</h3>
            <pre style="background-color: #f5f5f5; padding: 10px; border-radius: 5px; overflow-x: auto;">rh   ri   rk   u   
            <h3>📥 Request Data:</h3>
            <pre style="background-color: #f5f5f5; padding: 10px; border-radius: 5px; overflow-x: auto;">u  
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="UTF-8">
            <title>API Failure Alert</title>
        </head>
        <body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
            <div style="max-width: 800px; margin: 0 auto; padding: 20px;">
                <div style="background-color: #fd7e14; color: white; padding: 20px; border-radius: 10px; margin-bottom: 20px;">
                    <h1 style="margin: 0; font-size: 24px;">⚠️ API FAILURE ALERT</h1>
                    <p style="margin: 10px 0 0 0; font-size: 16px;">AI Test Case Generator System</p>
                </div>
                
                <div style="background-color: #f8f9fa; padding: 20px; border-radius: 10px; margin-bottom: 20px;">
                    <h2 style="color: #fd7e14; margin-top: 0;">API Failure Details</h2>
                    <p><strong>⏰ Timestamp:</strong> u<   </p>
                    <p><strong>🔌 API Name:</strong> uB   </p>
                    <p><strong>🌐 Endpoint:</strong> <code>z </code></p>
                    uD   <p><strong>📊 Status Code:</strong> <span style="color: #dc3545;">z</span></p>u  
                    <p><strong>📝 Error Message:</strong></p>
                    <div style="background-color: #fff; padding: 15px; border-left: 4px solid #fd7e14; margin: 10px 0;">
                        <code style="color: #dc3545; font-size: 14px;">rl   rm   u  
                
                <div style="background-color: #e9ecef; padding: 15px; border-radius: 5px; margin-top: 20px;">
                    <h3>🔧 Recommended Actions:</h3>
                    <ul>
                        <li>Check API service status and connectivity</li>
                        <li>Verify API credentials and authentication</li>
                        <li>Review API rate limits and quotas</li>
                        <li>Check for API endpoint changes or deprecations</li>
                        <li>Monitor API response times and error rates</li>
                    </ul>
                </div>
                
                <div style="text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid #dee2e6;">
                    <p style="color: #6c757d; font-size: 12px;">
                        This is an automated alert from the AI Test Case Generator monitoring system.
                    </p>
                </div>
            </div>
        </body>
        </html>
        r   rn   ro   rt   ru   )r!   rM   rN   r:   rO   rP   rQ   rw   response_htmlrequest_htmlr~   s              r"   rT   ,EmailNotifier._create_api_failure_email_body	  s'    LLN++,CD	 !jjnjtjt  vC  LM  kN  jO OM  jjnjtjt  vB  KL  kM  jN NL
8  9B{ C88@z B>>FZ H yD[\g[hhst  JL  M MH IV W    	70	d r%   c                 "   [         R                  " 5       R                  S5      nUS:X  a  SO	US:X  a  SOSnUS:X  a  SO	US:X  a  SOS	nS
nU(       a  S[        R                  " USS9 S3nSU SU SU SU SU SU SU SU SU SU SU S3n	U	$ )z(Create HTML email body for system alertsre   r[   z#dc3545r]   z#fd7e14z#17a2b8r\   r^   r_   rf   rg   rh   ri   rk   aa  
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="UTF-8">
            <title>System Alert</title>
        </head>
        <body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
            <div style="max-width: 800px; margin: 0 auto; padding: 20px;">
                <div style="background-color: z; color: white; padding: 20px; border-radius: 10px; margin-bottom: 20px;">
                    <h1 style="margin: 0; font-size: 24px;">a9   SYSTEM ALERT</h1>
                    <p style="margin: 10px 0 0 0; font-size: 16px;">AI Test Case Generator System</p>
                </div>
                
                <div style="background-color: #f8f9fa; padding: 20px; border-radius: 10px; margin-bottom: 20px;">
                    <h2 style="color: u\   ; margin-top: 0;">Alert Details</h2>
                    <p><strong>⏰ Timestamp:</strong> u>   </p>
                    <p><strong>🚨 Alert Type:</strong> uO   </p>
                    <p><strong>⚡ Severity:</strong> <span style="color: z; font-weight: bold;">u   </span></p>
                    <p><strong>📝 Message:</strong></p>
                    <div style="background-color: #fff; padding: 15px; border-left: 4px solid zH; margin: 10px 0;">
                        <p style="margin: 0; color: z; font-size: 14px;">zX</p>
                    </div>
                </div>
                
                u  
                
                <div style="background-color: #e9ecef; padding: 15px; border-radius: 5px; margin-top: 20px;">
                    <h3>🔧 Recommended Actions:</h3>
                    <ul>
                        <li>Review system logs and monitoring dashboards</li>
                        <li>Check system resources and performance metrics</li>
                        <li>Verify system configuration and dependencies</li>
                        <li>Monitor for any user impact or service degradation</li>
                    </ul>
                </div>
                
                <div style="text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid #dee2e6;">
                    <p style="color: #6c757d; font-size: 12px;">
                        This is an automated alert from the AI Test Case Generator monitoring system.
                    </p>
                </div>
            </div>
        </body>
        </html>
        r   )
r!   rW   rX   rY   r;   rw   colorra   ry   r~   s
             r"   r`   -EmailNotifier._create_system_alert_email_bodyU  s    LLN++,CD	 &3	hR[F[aj"j0I@Uf[a  jjnjtjtu|  FG  kH  jI IL
	/ 05g 6==BG D'
 (-g .88A{ C::D FKKP'Qghpgq r__d^e f55:G;OPWy Y  	3-	^ r%   rH   rI   rB   c                     U(       a  UOU R                   nU(       d  [        R                  S5        g[        S5      nXS'   U R                  US'   SR                  U5      US'   U(       a  UR                  [        US5      5        OUR                  [        US	5      5        U R                  (       a@  [        R                  " 5       n[        R                  " U R                  U R                  US
9nOL[        R                  " U R                  U R                  5      nU R                   (       a  UR#                  5         UR%                  U R&                  U R(                  5        UR+                  U5        UR-                  5         [        R/                  SSR                  U5       35        g! [0         a+  n	[        R                  S[3        U	5       35         Sn	A	gSn	A	ff = f)a  
Send email using SMTP

Args:
    subject: Email subject
    body: Email body
    is_html: Whether the body is HTML format
    recipients: List of email recipients (defaults to configured recipients)
    
Returns:
    bool: True if email sent successfully, False otherwise
zNo email recipients specifiedFalternativeSubjectFromr-   Tohtmlplain)r;   zEmail sent successfully to TzFailed to send email: N)r   r/   rF   r   r   r1   attachr   r   sslcreate_default_contextsmtplibSMTP_SSLr   r   SMTPr   starttlsloginr   r   send_messagequitr3   rE   rG   )
r!   rH   rI   rB   r   email_recipientsmsgr;   serverrJ   s
             r"   rD   EmailNotifier._send_email  se   '	-7zT__#<=  .C$	N++CK		"23CI 

8D&12

8D'23 ||446 ))$*:*:DNNT[\ d&6&6G<<OO% LL6$KKMKK5dii@P6Q5RST 	LL1#a&:;	s   1F0 E;F0 0
G%:!G  G%emailreset_token
expires_atc                 J   U R                   (       d  [        R                  S5        g SSKJn  SnU SU 3nUR                  S5      nU R                  XU5      nU R                  XXSU/S	9$ ! [         a+  n	[        R                  S
[        U	5       35         Sn	A	gSn	A	ff = f)z
Send password reset email

Args:
    email: User's email address
    reset_token: Password reset token
    expires_at: Token expiration time
    
Returns:
    bool: True if email sent successfully, False otherwise
z?Email notifications disabled - cannot send password reset emailFr   )BASE_URLu4   🔐 Password Reset Request - AI Test Case Generatorz/reset-password-confirm?token=z%B %d, %Y at %I:%M %p UTCTrA   z%Failed to send password reset email: N)r2   r/   r0   config.settingsr   ro   !_create_password_reset_email_bodyrD   rE   rF   rG   )
r!   r   r   r   r   rH   
reset_linkexpires_strrI   rJ   s
             r"   send_password_reset_email'EmailNotifier.send_password_reset_email  s     ||NN\]	0LG %:%CK=QJ %--.IJK 99%[YD ##G4UG#TT 	LL@QIJ	s   AA- -
B"7!BB"r   r   c                 r    [         R                  " 5       R                  S5      nSU SU SU SU SU S3nU$ )z)Create HTML email body for password resetre   u  
        <!DOCTYPE html>
        <html>
        <head>
            <meta charset="UTF-8">
            <title>Password Reset Request</title>
        </head>
        <body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
            <div style="max-width: 600px; margin: 0 auto; padding: 20px;">
                <div style="background-color: #007bff; color: white; padding: 20px; border-radius: 10px; margin-bottom: 20px;">
                    <h1 style="margin: 0; font-size: 24px;">🔐 Password Reset Request</h1>
                    <p style="margin: 10px 0 0 0; font-size: 16px;">AI Test Case Generator</p>
                </div>
                
                <div style="background-color: #f8f9fa; padding: 20px; border-radius: 10px; margin-bottom: 20px;">
                    <h2 style="color: #007bff; margin-top: 0;">Reset Your Password</h2>
                    <p>Hello,</p>
                    <p>We received a request to reset your password for your AI Test Case Generator account associated with <strong>aC  </strong>.</p>
                    
                    <div style="background-color: #fff; padding: 20px; border-radius: 5px; margin: 20px 0; text-align: center;">
                        <p style="margin: 0 0 15px 0; font-weight: bold;">Click the button below to reset your password:</p>
                        <a href="a[  " style="display: inline-block; background-color: #007bff; color: white; padding: 12px 30px; text-decoration: none; border-radius: 5px; font-weight: bold; font-size: 16px;">
                            Reset My Password
                        </a>
                    </div>
                    
                    <p style="margin: 20px 0 10px 0;"><strong>Or copy and paste this link into your browser:</strong></p>
                    <div style="background-color: #e9ecef; padding: 10px; border-radius: 5px; word-break: break-all; font-family: monospace; font-size: 14px;">
                        u  
                    </div>
                </div>
                
                <div style="background-color: #fff3cd; border: 1px solid #ffeaa7; padding: 15px; border-radius: 5px; margin-bottom: 20px;">
                    <h3 style="color: #856404; margin-top: 0;">⚠️ Important Security Information</h3>
                    <ul style="color: #856404; margin: 0;">
                        <li>This link will expire on <strong>u  </strong></li>
                        <li>The link can only be used once</li>
                        <li>If you didn't request this password reset, please ignore this email</li>
                        <li>Your password will remain unchanged until you click the link above</li>
                    </ul>
                </div>
                
                <div style="background-color: #e9ecef; padding: 15px; border-radius: 5px; margin-bottom: 20px;">
                    <h3 style="margin-top: 0;">🔒 Security Tips</h3>
                    <ul style="margin: 0;">
                        <li>Choose a strong, unique password</li>
                        <li>Don't share your password with anyone</li>
                        <li>Log out of your account when using shared computers</li>
                        <li>Contact support if you notice any suspicious activity</li>
                    </ul>
                </div>
                
                <div style="text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid #dee2e6;">
                    <p style="color: #6c757d; font-size: 12px; margin: 0;">
                        This email was sent on z<br>
                        If you have any questions, please contact our support team.
                    </p>
                </div>
            </div>
        </body>
        </html>
        )r   rn   ro   )r!   r   r   r   rw   r~   s         r"   r   /EmailNotifier._create_password_reset_email_body  sx     LLN++,CD	E" FK  EL L" #- . $ %> ?J] K0& 1:{ ;	m=	~ r%   c                 6   U R                   (       d  [        R                  S5        g SnS[        R                  " 5       R                  S5       S3nU R                  XSS9$ ! [         a+  n[        R                  S	[        U5       35         S
nAgS
nAff = f)z|
Test email configuration by sending a test email

Returns:
    bool: True if test email sent successfully, False otherwise
z8Email notifications disabled - cannot test configurationFu6   🧪 Email Configuration Test - AI Test Case Generatoru  
            <!DOCTYPE html>
            <html>
            <head>
                <meta charset="UTF-8">
                <title>Email Test</title>
            </head>
            <body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
                <div style="max-width: 600px; margin: 0 auto; padding: 20px;">
                    <div style="background-color: #28a745; color: white; padding: 20px; border-radius: 10px; text-align: center;">
                        <h1 style="margin: 0;">✅ Email Configuration Test Successful</h1>
                    </div>
                    <div style="background-color: #f8f9fa; padding: 20px; border-radius: 10px; margin-top: 20px;">
                        <p><strong>Timestamp:</strong> re   aq  </p>
                        <p><strong>Service:</strong> AI Test Case Generator</p>
                        <p><strong>Status:</strong> Email notifications are working correctly</p>
                    </div>
                    <div style="text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid #dee2e6;">
                        <p style="color: #6c757d; font-size: 12px;">
                            This is a test email to verify email notification configuration.
                        </p>
                    </div>
                </div>
            </body>
            </html>
            TrS   zFailed to send test email: N)
r2   r/   r0   r   rn   ro   rD   rE   rF   rG   )r!   rH   rI   rJ   s       r"   test_email_configuration&EmailNotifier.test_email_configuration9  s     ||NNUV!	NG8 9A8O8OPg8h7i jD6 ##G4#@@ 	LL6s1vh?@	s   9A# #
B-!BB)	r2   r   r   r   r   r   r   r   r   NNNNNNNr]   N)N)TN)__name__
__module____qualname____firstlineno____doc__r#   r    rG   r
   r   r	   rE   r   boolrK   intrU   rb   rC   rT   r`   rD   r   r   r   r   __static_attributes__ r%   r"   r   r      s   J O0 LPHLPTIM	#3 #s #08c3h0H#2:92E# 6>d38n5M# 4<DI3F	# SW	#L VZDHCG#c #S #36#EMc]#3;D># 3;4.# MQ#L Y]C # #&=Ed3PS8n=UaeB EIAEIM\3 \s \)1$sCx.)A\+3I+>\ /7tCH~.F\ SV\~ W[EIDHJs Jc J47JFNsmJ4<TNJ 4<D>J NQJZ Z^A# A A03A>FtCQTH~>VAbeAF43 4c 4D 4UYZ]U^ 4jn 4l#s # #RZ #_c #JDs D DZ] Dbe DL,$ ,r%   r   r9   r:   r;   r<   r=   r   r>   c                 0    [         R                  XX#XE5      $ )z&Send critical error notification email)email_notifierrK   )r9   r:   r;   r<   r=   r   s         r"   rK   rK   k  s     ::7| r%   rM   rN   rO   rP   rQ   c                 0    [         R                  XX#XE5      $ )z#Send API failure notification email)r   rU   )rM   rN   r:   rO   rP   rQ   s         r"   rU   rU   u  s    
 77M r%   rW   rX   rY   c                 .    [         R                  XX#5      $ )z$Send system alert notification email)r   rb   )rW   rX   rY   r;   s       r"   rb   rb   ~  s     ++JSSr%   r   r   r   c                 .    [         R                  XU5      $ )zSend password reset email)r   r   )r   r   r   s      r"   r   r     s    33E
SSr%   c                  *    [         R                  5       $ )zTest email configuration)r   r   r   r%   r"   r   r     s    2244r%   r   r   r   ),r   r   r   loggingemail.mime.textr   email.mime.multipartr   email.mime.baser   r   r   r   typingr   r	   r
   r   osrp   rt   r   r   r   r   r   r   r   r   r   	getLoggerr   r/   r   r   rG   rE   r   rK   r   rU   rb   r   r   r   r%   r"   <module>r      s  
  
  $ . $   , , 	    
 
		8	$L	 L	^  HLDHLPEI	 S ,4T#s(^,D.6y.A 2:$sCx.1I 08S	/B	 OS	 RV@D?CC 3 /2AI#/7~ /7tn IM UYT# T T"T9A$sCx.9QT]aT
TS Ts T TUY T5$ 5r%   