
    BiM                     t    d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	Z	 e	j
        e          ZddZd ZdS )	u   
이메일 발송 유틸리티
    N)MIMEText)MIMEMultipart)Headerc           	         	 t          j        dd          }t          t          j        dd                    }t          j        d          }t          j        d          }t          ||g          st                              d           dS t          d	          }||d
<   | |d<   t          |d          |d<   |r&t          |dd          }	|	                    |	           |r&t          |dd          }
|	                    |
           t          j        ||          }|                                 |                    ||           |                    |           |                                 t                              d|  d|            dS # t"          $ r8}t                              d|  dt'          |                      Y d}~dS d}~ww xY w)u   
    이메일 발송
    
    Args:
        to_email: 수신자 이메일
        subject: 제목
        body_html: HTML 본문 (선택)
        body_text: 텍스트 본문 (선택)
    
    Returns:
        bool: 발송 성공 여부
    SMTP_SERVERzsmtp.gmail.com	SMTP_PORT587SMTP_USERNAMESMTP_PASSWORDuP   SMTP 설정이 완료되지 않았습니다. 환경변수를 확인해주세요.FalternativeFromTozutf-8Subjecthtmlplainu   이메일 전송 완료: u
   , 제목: Tu   이메일 전송 실패: u
   , 오류: N)osgetenvintallloggerwarningr   r   r   attachsmtplibSMTPstarttlsloginsend_messagequitinfo	Exceptionerrorstr)to_emailsubject	body_html	body_textsmtp_server	smtp_portsmtp_usernamesmtp_passwordmsg	html_part	text_partserveres                P/var/www/html/web/mlink/mlink_AI_Server/mlink-backend/src/utils/email_service.py
send_emailr1      s   %i/?@@	+u5566		/22	/22M=122 	NNmnnn5 M**#FD	11I  	" FG<<IJJy!!! 	" GW==IJJy!!! k955]M222C   MMMGMMNNNt   MMMSVVMMNNNuuuuus   B
F DF 
G-GGc                 ~    d| d}d| d| d| d|dd| d	}d
| d| d| d|dd| d}t          | |||          S )u  
    결제 링크 이메일 발송
    
    Args:
        user_email: 사용자 이메일
        user_name: 사용자 이름
        subscription_name: 구독 상품명
        payment_link: 결제 링크 URL
        billing_date: 결제 예정일
        amount: 결제 금액
    z	[M-Link] u    구독 갱신 결제 안내u  
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <style>
            body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
            .container { max-width: 600px; margin: 0 auto; padding: 20px; }
            .header { background-color: #4CAF50; color: white; padding: 20px; text-align: center; }
            .content { padding: 20px; background-color: #f9f9f9; }
            .button { display: inline-block; padding: 12px 30px; background-color: #4CAF50; color: white; text-decoration: none; border-radius: 5px; margin: 20px 0; }
            .footer { padding: 20px; text-align: center; color: #666; font-size: 12px; }
        </style>
    </head>
    <body>
        <div class="container">
            <div class="header">
                <h1>M-Link 구독 갱신 결제 안내</h1>
            </div>
            <div class="content">
                <p>안녕하세요, u"   님</p>
                <p>M-Link un    구독 갱신 결제가 예정되어 있습니다.</p>
                <p><strong>결제 예정일:</strong> u8   </p>
                <p><strong>결제 금액:</strong> ,u   원</p>
                <p>아래 버튼을 클릭하여 결제를 완료해주세요.</p>
                <div style="text-align: center;">
                    <a href="u  " class="button">결제하기</a>
                </div>
                <p style="margin-top: 30px; font-size: 12px; color: #666;">
                    결제 링크가 만료되거나 문제가 있는 경우, M-Link 고객센터로 문의해주세요.
                </p>
            </div>
            <div class="footer">
                <p>© 2024 M-Link. All rights reserved.</p>
            </div>
        </div>
    </body>
    </html>
    u   
안녕하세요, u   님

M-Link uG    구독 갱신 결제가 예정되어 있습니다.

결제 예정일: u   
결제 금액: u   원

결제 링크: u\   

위 링크를 클릭하여 결제를 완료해주세요.

감사합니다.
M-Link 팀
    )r1   )	
user_email	user_namesubscription_namepayment_linkbilling_dateamountr$   r%   r&   s	            r0   send_payment_link_emailr:   B   s     J+IIIG&( &/)& &* -+& &, 8D-& &. 5;/& & &4 +5& & &IP  	 
         I  j'9i@@@    )NN)__doc__r   r   email.mime.textr   email.mime.multipartr   email.headerr   logging	getLogger__name__r   r1   r:    r;   r0   <module>rD      s     
			  $ $ $ $ $ $ . . . . . .       		8	$	$2 2 2 2hFA FA FA FA FAr;   