edZddlZddlZddlZddlZddlmZmZddlm Z ddl m Z ddl m Z ddlmZmZdd lmZdd lmZdd lmZmZd ed efdZGddZdS)z8 This module contains SSA Mailer class and helper tools N) ConfigParser SectionProxy) EmailMessage gethostname)is_cl_solo_edition) EnvironmentFileSystemLoader)mail_template_location)SSAMailerError) duration_cast format_date report_datareturncntttdd}t|jd<|d}||dtd}|d}|t|d | }||fS) zJ Render an HTML table for e-mail report and a full e-mail message T)loader trim_blocks lstrip_blocksrzreport_table.htmldomains)skip_jwt_check)ris_soloz mail.htmldate)r report_table) r r r rfilters get_templaterenderrr)renvtable_templater mail_templatemails J/opt/cloudlinux/venv/lib64/python3.11/site-packages/ssa/internal/mailer.pyrender_report_tabler#s  677   C $1CK %%&9::N!((Y1G1C<@2B2B2B)CCL$$[11M   [V1D%E%E-9  ; ;D  ceZdZdZdZedefdZedefdZ e dede fdZ de dd fd Zde dd fd Zd e dd fd Z ddededd fdZdedede fdZd S)Mailerz. Class contains SSA e-mail send logic cFtjd|_d|_dS)Nmailer)logging getLoggerlogger_senderselfs r"__init__zMailer.__init__6s'11  r$rcdS)z+ Local mail server address ) localhostr-s r" mail_serverzMailer.mail_server:s ~r$c$dtS)z% 'From' mail address zslow-site-analyzer@rr-s r"senderz Mailer.senderAs 5[]]444r$namectd|d}tj|r-t d}|||dSt d|dt)zF Get preformatted data for e-mail by name of template /z.iniN) interpolationdatazFailed to find template z in )r ospathexistsrreadr )r6tmplconfigs r" read_templatezMailer.read_templateHs )554555 7>>$   "!555F KK   &> ! It I I1G I IKK Kr$messageNc|jd tj|j5}||}|jd|ddddS#1swxYwYdS#tj$r$}tdt|d}~wttf$r$}tdt|d}~wwxYw)z= Send preformatted e-mail via localhost SMTP zTry to send via smtpzSend result: %sNzsmtp mailing failed: zsmtp connection failed: ) r+infosmtplibSMTPr3 send_message SMTPExceptionr strConnectionErrorOSError)r.rBserverresultes r" _smtp_sendzMailer._smtp_sendUs> /000 Ft/0 %s)rArr5 set_contentadd_alternativer+rDrW)r.rbrcrfr:msgs r"rezMailer._messages!!(++nni61IkF D  V v-... DL616BBB 0#--//BBB r$)ra)__name__ __module__ __qualname____doc__r/propertytupler3rIr5 staticmethodrrArrOr[r`rgrer2r$r"r&r&1sUX 5555X5  KC KL K K K\ K F, F4 F F F F K\ Kd K K K K , 4    &*6AA$'A#&A'+AAAA+r$r&)rtr)r;rErU configparserrr email.messagersocketrclcommon.lib.cleditionrjinja2r r constantsr exceptionsr utilsrrdictrvr#r&r2r$r"rs8 33333333&&&&&&55555500000000------&&&&&&--------Te,mmmmmmmmmmr$