ϪfdZddlZddlZddlmZddlmZddlmZGddZ Gdd Z Gd d e ejZ Gd d e ejZy)z Support for relaying mail. N) UNIXAddress)smtp)logc*eZdZdZddZdZdZdZy) DomainQueuerzM An SMTP domain which add messages to a queue intended for relaying. c ||_||_yN)serviceauthed)selfr authenticateds 4/usr/lib/python3/dist-packages/twisted/mail/relay.py__init__zDomainQueuer.__init__s # c|jjjrtdt j j dd}tdt jj dd}t|dk(rt|dk(rfdStj)a Check whether mail can be relayed to a user. @type user: L{User} @param user: A user. @rtype: no-argument callable which returns L{IMessage } provider @return: A function which takes no arguments and returns a message receiver for the user. @raise SMTPBadRcpt: When mail cannot be relayed to the user. N@c&jSr ) startMessage)r usersrz%DomainQueuer.exists..-st006r) willRelaydestprotocolfilterstrorigsplitlenr SMTPBadRcpt)r rrrs`` rexistszDomainQueuer.existss >>$))T]] 3$DII 4 4S! <=D$DII 4 4S! <=D4yA~#d)q.66t$$rc|jj}|jxs!t|txs|j dk(S)z Check whether we agree to relay. The default is to relay for all connections over UNIX sockets and all connections from localhost. z 127.0.0.1) transportgetPeerr isinstancerhost)r addressrpeers rrzDomainQueuer.willRelay0s<!!))+{{Wj{;WtyyK?WWrc |jj}|j\}}|5tjdt |j dt |jtjt |j t |jg|ddd|S#1swY|SxYw)z Create an envelope and a message receiver for the relay queue. @type user: L{User} @param user: A user. @rtype: L{IMessage } @return: A message receiver. zQueueing mail z -> N) r queuecreateNewMessagermsgrrrpickledump)r rr+ envelopeFile smtpMessages rrzDomainQueuer.startMessage:s ""$)$:$:$<! k  H GGnS^$6d3tyy>:LM N KKTYYTYY8, G H Hs BB66CN)F)__name__ __module__ __qualname____doc__rr"rrrrrrs$%,Xrrc*eZdZdZdZdZdZdZy) RelayerMixincJg|_g|_|D]}t|dzd5}tj|}dddt|dz}j ||jj ||jj |y#1swYaxYw)N-Hrb-D)messagesnamesopenr.loadappend)r messagePathsmessagefpmessageContentss r loadMessageszRelayerMixin.loadMessagesQs  # 'Ggnd+ 2r"(++b/ 2gn%B  " "2 & MM  1 JJ  g &  ' 2 2s BB" c@|jsy|jddS)Nrr=r s r getMailFromzRelayerMixin.getMailFrom\ }}}}Q""rcB|jsy|jddgS)NrrrHrIs r getMailTozRelayerMixin.getMailToas#}} a #$$rc@|jsy|jddS)NrrrHrIs r getMailDatazRelayerMixin.getMailDatafrKrc|tjvrJtj|jddztj|jddz|j d=|jd=y)zSince we only use one recipient per envelope, this will be called with 0 or 1 addresses. We probably want to do something with the error message if we failed. rr<r:N)rSUCCESSosremover>r=)r coderespnumOk addressesrs rsentMailzRelayerMixin.sentMailksY 4<<  IIdjjmd* + IIdjjmd* + MM!  JJqMrN)r2r3r4rFrJrMrOrXr6rrr8r8Ls '# % # rr8ceZdZdZdZy) SMTPRelayerz) A base class for SMTP relayers. cltjj|g|i||j|y)a @type messagePaths: L{list} of L{bytes} @param messagePaths: The base filename for each message to be relayed. @type args: 1-L{tuple} of (0) L{bytes} or 2-L{tuple} of (0) L{bytes}, (1) L{int} @param args: Positional arguments for L{SMTPClient.__init__} @type kw: L{dict} @param kw: Keyword arguments for L{SMTPClient.__init__} N)r SMTPClientrrFr rBargskws rrzSMTPRelayer.__init__}s.   333 ,'rNr2r3r4r5rr6rrrZrZxs  (rrZceZdZdZdZy) ESMTPRelayerz* A base class for ESMTP relayers. cltjj|g|i||j|y)a @type messagePaths: L{list} of L{bytes} @param messagePaths: The base filename for each message to be relayed. @type args: 3-L{tuple} of (0) L{bytes}, (1) L{None} or L{ClientContextFactory }, (2) L{bytes} or 4-L{tuple} of (0) L{bytes}, (1) L{None} or L{ClientContextFactory }, (2) L{bytes}, (3) L{int} @param args: Positional arguments for L{ESMTPClient.__init__} @type kw: L{dict} @param kw: Keyword arguments for L{ESMTPClient.__init__} N)r ESMTPClientrrFr]s rrzESMTPRelayer.__init__s0" !!$444 ,'rNr`r6rrrbrbs (rrb)r5rRr.twisted.internet.addressr twisted.mailrtwisted.pythonrrr8r\rZrdrbr6rrrhsW  088v))X(,(*(<!1!1(r