a ����á·´gO��ã�������������������@���sÎ���d�dl�Z�d�dlmZ�d�dlZd�dlZd�dlmZ�d�dlmZm Z m Z mZmZm Z mZmZmZmZmZmZ�dZejdejejejdZejejdZed ƒZed ƒZedƒZedƒZ ed ƒZ!G�dd„�de"ƒZ#dS�)é����N)ÚTemplate)ÚConfig)ÚAsmÚContentÚEmailÚMailÚToÚ AttachmentÚFileNameÚFileTypeÚDispositionÚFileContentÚGroupIdÚGroupsToDisplayúMessage from SPARC PortalÚses)Úaws_access_key_idÚaws_secret_access_keyÚregion_name)Úapi_keyzc<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 z²<b>Thank you for expressing interest in a SPARC service! We have received your request and will be in contact as soon as possible.</b> <br> <br> Your message: <br> <br> $message z<b>Thank you for your submission to SPARC! We have received your question/inquiry and will be in contact as soon as possible.</b> <br> <br> Your message: <br> <br> $message z<b>Thank you for the following SPARC submission! We have received your request and will be in contact as soon as possible.</b> <br> <br> Your submission: <br> <br> $message c�������������������@���s4���e�Zd�Zdd„�Zdd„�Zdd„�Zdd„�Zd d „�ZdS�)ÚEmailSenderc�����������������C���s<���d|�_�d|�_tj|�_tj|�_d|�_tjdkr8t tjƒ|�_d�S�)Nr���zUTF-8r���Ú�) Údefault_subjectÚcharsetr���Ú SES_SENDERÚ ses_senderÚSES_ARNÚses_arnÚunsubscribe_groupÚ(SENDGRID_MONTHLY_STATS_UNSUBSCRIBE_GROUPÚint)Úself©�r"���ú?/home/cmiss/Jenkins/workspace/SPARC-API/scripts/email_sender.pyÚ__init__F���s���� zEmailSender.__init__c�����������������C���sR���|d�|�d�|�}t�j|�jd|�jgi|�j|�jdœd|�j|dœidœ|�jd�d�S�)NÚ ZToAddresses)ÚCharsetZDataÚText)ZSubjectÚBody)ÚSourceZDestinationÚMessageZ SourceArn)Ú ses_clientÚ send_emailr���r���r���r���)r!���ÚnameÚ email_addressÚmessageÚbodyr"���r"���r#���r,���O���s���� þùzEmailSender.send_emailc�����������������C���s€���t�t|ƒt|ƒ|td|ƒƒ}tt|ƒt|ƒt|ƒtdƒƒ} | |_ t |¡} t d|›�d¡�t d|›�d| j›�d| j›�¡�| S�)Nú text/htmlÚ attachmentúSending a 'z%' mail with attachment using SendGridúMail to ú response Status code: r%���)r���r���r���r���r ���r ���r ���r���r���r2���Ú sg_clientÚsendÚloggingÚinfoÚdebugÚstatus_coder0���)r!���ÚfrommÚtoÚsubjectr0���Zencoded_fileÚ file_nameÚ file_typeÚmailZattachedFileÚresponser"���r"���r#���Úsendgrid_email_with_attachment\���s"����üü z*EmailSender.sendgrid_email_with_attachmentc�����������������C���s\���t�t|ƒt|ƒ|td|ƒƒ}t |¡}t d|›�d¡�t d|›�d|j ›�d|j ›�¡�|S�©Nr1���r3���z' mail using SendGridr4���r5���r%���)r���r���r���r���r6���r7���r8���r9���r:���r;���r0���©r!���r<���r=���r>���r0���rA���rB���r"���r"���r#���Úsendgrid_emailp���s����ü zEmailSender.sendgrid_emailc�����������������C���sv���t�t|ƒt|ƒ|td|ƒƒ}tt|�jƒt|�jgƒƒ|_t |¡}t d|›�d¡�t d|›�d|j›�d|j›�¡�|S�rD���)r���r���r���r���r���r���r���r���Zasmr6���r7���r8���r9���r:���r;���r0���rE���r"���r"���r#���Ú%sendgrid_email_with_unsubscribe_group|���s����ü z1EmailSender.sendgrid_email_with_unsubscribe_groupN)Ú__name__Ú __module__Ú__qualname__r$���r,���rC���rF���rG���r"���r"���r"���r#���r���E���s ��� r���)$r8���Ústringr���Úboto3ZsendgridÚ app.configr���Zsendgrid.helpers.mailr���r���r���r���r���r ���r ���r���r���r ���r���r���r>���ÚclientÚSPARC_PORTAL_AWS_KEYÚSPARC_PORTAL_AWS_SECRETÚ AWS_REGIONr+���ZSendGridAPIClientÚSENDGRID_API_KEYr6���Úfeedback_emailÚissue_reporting_emailÚservice_interest_emailÚgeneral_interest_emailÚ#creation_request_confirmation_emailÚobjectr���r"���r"���r"���r#���Ú<module>���s&���8ü