
    hh(                     X   S r SSKrSSKrSSKrSSKrSSKJr  SSKJ	r	  SSK
Jr  SSKJr  SSKJrJr  SSKJr  S	r\R(                  R+                  S
5      rSrSr\" \R2                  5      r\" \S9r " S S5      rS r\" S5      rS r  " S S5      r!S r"S r#Sq$S r%S r&S r'S r(S r)g)z4
Implementation module for the I{mailmail} command.
    N)ConfigParser)StringIO)version)reactor)LoggertextFileLogObserver)smtpz/etc/mailmailz~/.twisted/mailmailz	127.0.0.1zSubject: Failed Message Delivery

  Message delivery failed.  The following occurred:

  %s
--
The Twisted sendmail application.
)observerc                       \ rS rSrSrSrg)Options(   aP  
Store the values of the parsed command-line options to the I{mailmail}
script.

@type to: L{list} of L{str}
@ivar to: The addresses to which to deliver this message.

@type sender: L{str}
@ivar sender: The address from which this message is being sent.

@type body: C{file}
@ivar body: The object from which the message is to be read.
 N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       d/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/mail/scripts/mailmail.pyr   r   (   s    r   r   c                  x     [         R                  " 5       $ ! [         a    [        R                  " 5       s $ f = fN)osgetloginBaseExceptiongetpassgetuserr   r   r   r   r   8   s/    !{{} !  !s    99zUnsupported option.c                    [        5       nU  Vs/ s H  o"R                  S5      (       a  M  UPM     snUl        [        5       Ul        SU ;   a  [        S[        5        [        5       eSU ;   a  [        eSU ;   a  [        eSU ;   a@  X R                  S5      S-      Ul        UR                  R                  UR                  5        SU ;   d  S	U ;   a  [        eS
U ;   a  SUl        OSUl        SU ;   a  SUl        OSUl        SU ;   d  SU ;   a  SUl        OSUl        SU ;   a  [        eSU ;   a   SUl        UR                  Ul        / Ul        OSUl        / Ul        / / / / / S.n[!        5       n Sn["        R$                  R'                  5       nUR)                  5       (       d  OUR+                  SS5      nUS   R-                  5       nUR                  (       aN  US;   aH  UR                  R/                  [0        R2                  R5                  US   5      S   /5        US:X  a  SnO0US:X  a*  [0        R2                  R5                  US   5      S   Ul        X;   a  X8   R7                  US   5        U(       a  UR9                  U5        GM   US   (       d  UR9                  SUR                   S35        US   (       dU  UR                  (       d  [        S5      eUR9                  SR;                  SR=                  UR                  5      5      5        US   (       d(  UR9                  S[>        R@                  " 5        S35        UR9                  U5        UR                  (       a/  UR                   H  n	 UR                  R                  U	5        M!     URE                  SS5        [!        URG                  5       ["        R$                  RI                  5       -   5      Ul%        U$ s  snf ! [B         a     M  f = f) N-z	--versionzmailmail version:z-bpz-bsz-F   z-iz-oiz-odbTFz-odfz-oepz-epz-omz-t)fromtoccbccdatez: r   )r"   r#   r$   r$   r!   zFrom: z
r"   zNo recipients specified.zTo: {}
z, r%   zDate: )&r   
startswithr"   r   senderprintr   
SystemExit_unsupportedOptionindexremove
backgroundprintErrorsrecipientsFromHeadersexcludeAddressesexludeAddressesr   sysstdinreadlinestripsplitlowerextendemailutils	parseaddrappendwriteformatjoinr	   
rfc822dater   seekgetvaluereadbody)
argvoerequiredHeadersbufferr=   linehdrshdras
             r   parseOptionsrN   B   s\   	A5t!<<#4At5ADzAH d!7+l }   }   t|

4(1,-	AHH 	%4-   ~ ~ 	$ETM }  
 t|"&TT"' O ZF
yy!!#zz||zz$"1gmmo""s.A'ADDKK..tAw7:;<e|F]{{,,T!W5a8AH! ''Q0LL) , 6"vahhZt,-4 tt788\((1449:6"vdoo/056
LL##AA $ KK1foo'#))..*::;AFHk 6` ! s   O-O-=O22
P ?P c                       \ rS rSrSrS rSrg)Configuration   a  

@ivar allowUIDs: A list of UIDs which are allowed to send mail.
@ivar allowGIDs: A list of GIDs which are allowed to send mail.
@ivar denyUIDs: A list of UIDs which are not allowed to send mail.
@ivar denyGIDs: A list of GIDs which are not allowed to send mail.

@type defaultAccess: L{bool}
@ivar defaultAccess: L{True} if access will be allowed when no other access
control rule matches or L{False} if it will be denied in that case.

@ivar useraccess: Either C{'allow'} to check C{allowUID} first
or C{'deny'} to check C{denyUID} first.

@ivar groupaccess: Either C{'allow'} to check C{allowGID} first or
C{'deny'} to check C{denyGID} first.

@ivar identities: A L{dict} mapping hostnames to credentials to use when
sending mail to that host.

@ivar smarthost: L{None} or a hostname through which all outgoing mail will
be sent.

@ivar domain: L{None} or the hostname with which to identify ourselves when
connecting to an MTA.
c                     / U l         / U l        / U l        / U l        SU l        SU l        0 U l        S U l        S U l        SU l	        g )NdenyT)
	allowUIDsdenyUIDs	allowGIDsdenyGIDs
useraccessgroupaccess
identities	smarthostdomaindefaultAccess)selfs    r   __init__Configuration.__init__   sJ     !!r   )
rV   rT   r]   rW   rU   r\   rY   rZ   r[   rX   N)r   r   r   r   r   r_   r   r   r   r   rP   rP      s    6"r   rP   c                    [        5       n[        R                  " U [        R                  5      (       d  U$ [	        5       nUR                  U 5        UR                  nUR                  nUR                  nUR                  nSX44SXV44 GH&  u  pxn	UR                  U5      (       d  M  SU4SU	44 Hy  u  pUR                  Xz5      (       d  M  UR                  Xz5      (       d  M5  UR                  Xz5      R                  S5       H   n [        U5      nUR                  U5        M"     M{     UR                  US	5      nUR                  S5       Vs/ s H  oR)                  5       PM     sn Vs/ s H  oR                  5       PM     nnUS   S:X  a  [+        XS5        GM  [+        XS5        GM)     UR                  S
5      (       aa  UR-                  S
5       HL  u  nnUR                  SS5      n[/        U5      S:w  a  ["        R%                  SUS9  M=  UUR0                  U'   MN     UR                  S5      (       a\  UR                  SS5      (       a  UR                  SS5      Ul        UR                  SS5      (       a  UR                  SS5      Ul        U$ ! [          a,    ["        R%                  SUS   R'                  5       UUS9   GM  f = fs  snf s  snf )NrX   rY   allowrS   ,z6Illegal {prefix}ID in [{section}] section: {sectionID}r   )prefixsection	sectionIDorderidentity:r       z.Illegal entry in [identity] section: {section})re   	addressesr[   default_domain)rP   r   accessR_OKr   rC   rT   rU   rV   rW   has_section
has_optiongetr6   intr<   
ValueError_logerrorupperr7   setattritemslenrZ   r[   r\   )pathcpauduagdgre   rM   dmodeLrf   rg   shostuppartss                     r   
loadConfigr      sm     	A99T277##AFF4L	
B	
B	
B	
B'0="2IJA==!!$aL61+6<<..1553G3G%&UU7%9%?%?%D	0(+II HHY/ &E 7 EE'7+E<AKK<L(M<Lq<L(MN(M1WWY(MENQx7"G,F+- K0 	}}Z  
+HD"HHS!$E5zQ

KUW
X!&ALL , 	}}[!!<<[11%%[9AK<<%566uu[*:;AHH?  *  JJ!C'.qz'7'7'9(/*3 '  )NNs   
J K1K 1K	K	c                 .    [         R                  " 5         g r   r   stop)results    r   successr   ,  s    LLNr   c                 2    [         R                  " 5         U qg r   )r   r   failed)fs    r   failurer   3  s    LLNFr   c                     [         R                  " XR                  UR                  UR                  5      nUR                  [        [        5        [        R                  " 5         g r   )
r	   sendmailr'   r"   rD   addCallbacksr   r   r   run)r   optionsidentr   s       r   r   r   9  s7    dNNGJJEANN7G$KKMr   c                 d   UR                   /nSR                  [        R                  S   [        R
                  R                  S5      5      n[        5       nU R                  US9  [        [        UR                  5       -  5      n[        R                  " SX2U5      nUR                  S 5        g )Nz2"Internally Generated Message ({})"<postmaster@{}>r   asciifile	localhostc                 ,    [         R                  " 5       $ r   r   )_s    r   <lambda>senderror.<locals>.<lambda>H  s
    r   )r'   r>   r2   rE   r	   DNSNAMEdecoder   printTraceback	ERROR_FMTrB   r   addBoth)r   r   	recipientr'   ru   rD   r   s          r   	senderrorr   ?  s     IAHHT\\((1F JE&I 001Dk6d;AII&'r   c                    [         R                  " 5       n[         R                  " 5       nU R                  S:X  a!  XR                  ;   a  gXR
                  ;   a  gO XR
                  ;   a  gXR                  ;   a  gU R                  S:X  a!  X R                  ;   a  gX R                  ;   a  gO X R                  ;   a  gX R                  ;   a  gU R                  (       + $ )NrS   TF)
r   getuidgetgidrX   rU   rT   rY   rW   rV   r]   )confuidgids      r   rS   rS   K  s    
))+C
))+C& --..  ! .. --6!--..  ! .. --!!!!r   c                  
   [        [        R                  SS  5      n [        [        5      n[        [
        5      n[        U5      (       d  [        U5      (       a  [        R                  S5        g UR                  =(       d    UR                  =(       d    [        nUR                  R                  5       nUR                  UR                  5        UR                  (       a  UR                  [        l        O&UR                  (       a  UR                  [        l        [#        X0U5        [$        (       aN  U R&                  (       a,  [$        R)                  [        R*                  S9  [-        S5      e[/        [$        U 5        g g )Nr    zPermission deniedr   )rN   r2   rE   r   
GLOBAL_CFG	LOCAL_CFGrS   rt   ru   r[   	SMARTHOSTrZ   copyupdater\   r	   r   r   r   r.   r   stderrr)   r   )rF   gConflConfr   r   s        r   r   r   h  s    SXXab\"Az"Ey!EE{{d5kk

&'??:eoo:D!!#E	LL!!"||||	||Tev==!!szz!2Q-fa  r   )*r   email.utilsr9   r   r   r2   configparserr   ior   twisted.copyrightr   twisted.internetr   twisted.loggerr   r   twisted.mailr	   r   rz   
expanduserr   r   r   r   _logObserverrt   r   r   r)   r*   rN   rP   r   r   r   r   r   r   rS   r   r   r   r   <module>r      s   

   	 
 %  % $ 6 
GG45			 #3::.|$  !   56 wt(" ("VBJ 
	(":!r   