o
    Xh*                     @   s   d dl Z d dlmZ d dlZd dlmZ d dlmZ d dlm	Z	 dZ
ejdejejejdZeejZed	Zed
Zede	 dZede	 dZede	 dZG dd deZdS )    N)Template)emails)Config)sparc_logo_base64Message from SPARC Portalses)aws_access_key_idaws_secret_access_keyregion_namezc<b>Thank you for your feedback on the SPARC Portal!</b>
<br>
<br>
Your message:
<br>
<br>
$message
za<b>Thank you for reporting the following error/issue on the SPARC Portal!</b>
<br>
<br>
$message
u  <html>
  <body style="font-family: Arial, sans-serif; line-height: 1.6;">

    <p>Hi $name,</p>

    <p>Thank you for your submission!</p>

    <p>We've successfully received your form and appreciate you taking the time to provide this information. The information you submitted is included below for your records.</p>

    <p>The SPARC Data and Resource Center (DRC) has a depth of expertise in developing and supporting digital resources that can be shared, cited, visualized, computed, and used for virtual experimentation. Your interest in SPARC supports FAIR data principles—making research data Findable, Accessible, Interoperable, and Reusable. We truly appreciate your commitment to contributing to the broader scientific community and supporting efforts that will benefit researchers for years to come.</p>

    <p>Our team will review your submission and make our best effort to get back to you within the next 5 business days. If you have any questions in the meantime, please don't hesitate to contact us at <a href="mailto:services@sparc.science">services@sparc.science</a>.</p>

    <p>Thank you again for your dedication to advancing scientific progress.</p>

    <p>Best regards,<br/>
    SPARC Data and Resource Center</p>

    <p>
      <img src="a\  " alt="SPARC Logo" style="max-width: 200px; height: auto; margin-bottom: 20px;"/><br/>
      <a href="https://sparc.science">https://sparc.science</a><br/>
      NIH-approved, HEAL-compliant repository<br/>
      Registered with re3data.org
    </p>

    <p>
      Your submission:
      <br/>
      <br/>
      $message
    </p>
  </body>
</html>
u,  <html>
  <body style="font-family: Arial, sans-serif; line-height: 1.6;">

    <p>Hi $name,</p>

    <p>Thank you for your submission!</p>

    <p>We've successfully received your form and appreciate you taking the time to provide this information. The information you submitted is included below for your records.</p>

    <p>By participating in this process, you're helping advance FAIR data principles—making research data Findable, Accessible, Interoperable, and Reusable. We truly appreciate your commitment to contributing to the broader scientific community and supporting efforts that will benefit researchers for years to come.</p>

    <p>Our team will review your submission and get back to you within the next 3 business days. If you have any questions in the meantime, please don't hesitate to contact us at <a href="mailto:services@sparc.science">services@sparc.science</a>.</p>

    <p>Thank you again for your dedication to advancing scientific progress.</p>

    <p>Best regards,<br/>
    SPARC Data and Resource Center</p>

    <p>
      <img src="u  <html>
  <body style="font-family: Arial, sans-serif; line-height: 1.6;">

    <p>Hi $name,</p>

    <p>Thank you for your submission!</p>

    <p>We've successfully received your form and appreciate you taking the time to provide this information. The information you submitted is included below for your records.</p>

    <p>By participating in this process, you're helping advance FAIR data principles—making research data Findable, Accessible, Interoperable, and Reusable. Through our partnership between Autonomic Neuroscience: Basic and Clinical and <a href="https://sparc.science/">SPARC</a>, we're working together to create a more robust and accessible scientific ecosystem. We truly appreciate your commitment to contributing to the broader scientific community and supporting efforts that will benefit researchers for years to come.</p>

    <p>Our team will review your submission and get back to you within the next 3 business days. If you have any questions in the meantime, please don't hesitate to contact us at <a href="mailto:services@sparc.science">services@sparc.science</a>.</p>

    <p>Thank you again for your dedication to advancing scientific progress.</p>

    <p>Best regards,<br/>
    SPARC Data and Resource Center</p>

    <p>
      <img src="c                   @   s.   e Zd Zdd Zdd Zd
ddZdd	 ZdS )EmailSenderc                 C   s&   d| _ d| _tj| _tj| _d| _d S )Nr   zUTF-8zSPARC Portal)default_subjectcharsetr   
SES_SENDER
ses_senderSES_ARNses_arn	from_name)self r   C/home/cmiss/Jenkins/workspace/SPARC-API-DEV/scripts/email_sender.py__init__   s
   
zEmailSender.__init__c                 C   sR   | d| d| }t j| jd| jgi| j| jdd| j|did| jd d S )N
ZToAddresses)CharsetZDataText)ZSubjectBody)SourceZDestinationMessageZ	SourceArn)
ses_client
send_emailr   r   r   r   )r   nameemail_addressmessagebodyr   r   r   r      s   

zEmailSender.send_emailNc           	      C   s|   || j dd|ig||d}|r||p|d|d< t|}|jds(tdtd| d td	| d
|  |S )Nemailr   r$   )fromtosubjecthtmlZreply_to2Email failed to send.Sending a 'z' mail using MailerSendMail to  response: 	r   mailersendstatus_code
startswith	Exceptionlogginginfodebug)	r   
from_emailr&   r'   r"   Zreply_to_emailZreply_to_namedataresponser   r   r   mailersend_email   s   


zEmailSender.mailersend_emailc                 C   sx   |||dd}|| j dd|ig|||gd}	t|	}
|
jds&tdtd| d	 td
| d|
  |
S )N
attachment)contentfilenametypedispositionr#   r$   )r%   r&   r'   r(   attachmentsr)   r*   r+   z'' mail with attachment using MailerSendr,   r-   r.   )r   r7   r&   r'   r"   Zencoded_file	file_name	file_typer;   r8   r9   r   r   r    mailersend_email_with_attachment   s"   

z,EmailSender.mailersend_email_with_attachment)NN)__name__
__module____qualname__r   r   r:   rC   r   r   r   r   r      s
    
r   )r4   stringr   boto3Z
mailersendr   
app.configr   Zstatic.sparc_logo_base64r   r'   clientSPARC_PORTAL_AWS_KEYSPARC_PORTAL_AWS_SECRET
AWS_REGIONr   ZNewEmailMAILERSEND_API_KEYr/   feedback_emailissue_reporting_email2service_form_submission_request_confirmation_email#creation_request_confirmation_email-anbc_form_creation_request_confirmation_emailobjectr   r   r   r   r   <module>   s4    

$
$
$