; = Dc@sdkZdkZdklZdklZlZdklZdk l Z l Z dk l Z dZdefdYZd eifd YZd e fd YZd fdYZdfdYZdS(N(ssmtp(sreactorsdefer(s ESMTPFactory(sLOGINCredentialssPLAINCredentials(s BasePlugins sMailUsercBs5tZdZdZdZdZdZRS(NcCs"||_|i|_d|_dS(Ns(susersselfsgwhmshostmasksrbuf(sselfsuser((s./Gateway/gwsmtp.pys__init__)s  cCsd|i||f|_dS(Ns %s [%s] %s(sselfsrbufsinreplysreply(sselfsreplysinreply((s./Gateway/gwsmtp.pys sendReply.scCs6|ii|t}|i|_||_|SdS(N(sselfscbs authorisedsConsoleMessageDeliverysmdssmtpuser(sselfsmd((s./Gateway/gwsmtp.pysgetMessageDelivery1s    cCst|iod}tid|d|ddd|id|ig}|ii d}|iii i d |it i|||i|d|_|indS( Nssupybot@supybot.supybotsFrom: %ss Reply-to: %ss Subject: %ss Supybot ReplysTo: %ssssmtpHostsReplying to %s by email.(slensselfsrbufsfadsRNLsjoinsaddresssmsgscbspersonalRegistryValuessmtphslogsinfossmtpssendmailsclose(sselfssmtphsmsgsfad((s./Gateway/gwsmtp.pysreply8s7 cCs$|ii|iii|dS(N(sselfsusers clearAuthscbs _connectionssremove(sself((s./Gateway/gwsmtp.pyscloseGs (s__name__s __module__s__init__s sendReplysgetMessageDeliverysreplysclose(((s./Gateway/gwsmtp.pysMailUser(s     sSBESMTPcBstZdZRS(NcCso|ioQ|i|_|i}ti|d }|i d|d|_ ||_n|i dddS(NiiNsAUTHis Temporary authentication failure( sselfsportalspeers challengers getChallenges challengesbase64s encodestringscodedssendCodesmode(sselfs challengerscodeds challenge((s./Gateway/gwsmtp.pys authenticateLs     (s__name__s __module__s authenticate(((s./Gateway/gwsmtp.pysSBESMTPKssMailGWcBsctZeZeZdZdZddddfddd d fgZd Z d e fd YZ RS(NiA#ssmtpssmtpHostsStrings localhosts1The address of the SMTP server used to send mail.s replyWaitsIntegeri,sThe number of seconds a session will last before completing and replying. Note that this is also the length of time smtp users will remain connected to receive walls.cGs(|i|i|_|i|i_dS(N(sselfs FactoryClasssportalsfactory(sselfsargs((s./Gateway/gwsmtp.pys factoryInitcss FactoryClasscBs tZeZdZdZRS(NcOs>ti|||t|_hdt<dt<|_ dS(NsLOGINsPLAIN( s ESMTPFactorys__init__sselfsaskwsConsoleMessageDeliverysdeliverysLOGINCredentialssPLAINCredentialss challengers(sselfsaskw((s./Gateway/gwsmtp.pys__init__is cCs2ti||}|i|_|i|_|SdS(N(s ESMTPFactorys buildProtocolsselfsaddrspshostspeersportal(sselfsaddrsp((s./Gateway/gwsmtp.pys buildProtocolqs  (s__name__s __module__sSBESMTPsprotocols__init__s buildProtocol(((s./Gateway/gwsmtp.pys FactoryClassgs ( s__name__s __module__sTrues PORTALISEsMailUsers USERCLASSs DEFAULT_PORTsPROTOCOLs CONFIG_EXTRAs factoryInits ESMTPFactorys FactoryClass(((s./Gateway/gwsmtp.pysMailGWWs$ sConsoleMessageDeliverycBs/tZeifZdZdZdZRS(NcCsdSdS(Ns Received: ConsoleMessageDelivery((sselfshelosorigins recipients((s./Gateway/gwsmtp.pysreceivedHeader|scCs|SdS(N(sorigin(sselfshelosorigin((s./Gateway/gwsmtp.pys validateFromscs4|iidjodSnti|dS(NssupybotcstiiS(N(sConsoleMessagesselfssmtpuserscb((sself(s./Gateway/gwsmtp.pyss(susersdestslocalssmtps SMTPBadRcpt(sselfsuser((sselfs./Gateway/gwsmtp.pys validateTos(s__name__s __module__ssmtpsIMessageDeliverys__implements__sreceivedHeaders validateFroms validateTo(((s./Gateway/gwsmtp.pysConsoleMessageDeliveryys   sConsoleMessagecBs8tZeifZdZdZdZdZRS(NcCsg|_||_||_dS(N(sselfslinesscbscon(sselfsconscb((s./Gateway/gwsmtp.pys__init__s  cCs|ii|dS(N(sselfslinessappendsline(sselfsline((s./Gateway/gwsmtp.pys lineReceivedscCsdi|i}ti|}d|jo|d|i_n"d|jo|d|i_n|i i d}x@t |D]2\}}tid||iii||iqWti|iid|iit|_titSdS(Ns sReply-tosFromis replyWait(sjoinsselfslinesstsemailsmessage_from_stringsmsgsconsaddresss get_payloadssplitscontents enumeratesislsreactors callLaterscbsreceivedCommandspersonalRegistryValuesreplysNonesdeferssucceed(sselfsislscontentstsmsg((s./Gateway/gwsmtp.pys eomReceiveds      cCs t|_dS(N(sNonesselfslines(sself((s./Gateway/gwsmtp.pysconnectionLosts( s__name__s __module__ssmtpsIMessages__implements__s__init__s lineReceiveds eomReceivedsconnectionLost(((s./Gateway/gwsmtp.pysConsoleMessages     (semailsbase64stwisted.protocolsssmtpstwisted.internetsreactorsdeferstwisted.mail.protocolss ESMTPFactorystwisted.protocols.imap4sLOGINCredentialssPLAINCredentialssgwbases BasePluginsRNLsobjectsMailUsersESMTPsSBESMTPsMailGWsConsoleMessageDeliverysConsoleMessage(sdefersSBESMTPs BasePluginsreactorsPLAINCredentialssRNLsMailGWsbase64ssmtps ESMTPFactorysLOGINCredentialssMailUsersConsoleMessagesemailsConsoleMessageDelivery((s./Gateway/gwsmtp.pys?s     # "