Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
 lŽŒYhªã @sWdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZdddddd d d d d ddg ZdZdZdZdZdZejdejƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd „d eƒZ Gdd „d eƒZ!Gdd „d eƒZ"Gd d „d eƒZ#d!d „Z$d"d#„Z%d$d„Z&d%d&„Z'd'd(„Z(yddl)Z)Wne*k r9d)Z+YnXd*Z+Gd+d„dƒZ,e+r|Gd,d-„d-e,ƒZ-ej.d-ƒd.Z/Gd/d0„d0e,ƒZ0e1d1krSd2d3„Z2e2d4ƒZ3e2d5ƒj4d6ƒZ5e6d7ƒd8Z7x%e j8j9ƒZ:e: rûPe7e:Z7qäWe6d9e;e7ƒƒe,d:ƒZ<e<j=d;ƒe<j>e3e5e7ƒe<j?ƒdS)>> import smtplib >>> s=smtplib.SMTP("localhost") >>> print(s.help()) This is Sendmail version 8.8.4 Topics: HELO EHLO MAIL RCPT DATA RSET NOOP QUIT HELP VRFY EXPN VERB ETRN DSN For more info use "HELP ". To report bugs in the implementation send email to sendmail-bugs@sendmail.org. For local information send email to Postmaster at your site. End of HELP info >>> s.putcmd("vrfy","someone@here") >>> s.getreply() (250, "Somebody OverHere ") >>> s.quit() éN)Ú body_encodeÚ SMTPExceptionÚSMTPServerDisconnectedÚSMTPResponseExceptionÚSMTPSenderRefusedÚSMTPRecipientsRefusedÚ SMTPDataErrorÚSMTPConnectErrorÚ SMTPHeloErrorÚSMTPAuthenticationErrorÚ quoteaddrÚ quotedataÚSMTPéiÑz s i z auth=(.*)c@seZdZdZdS)rz4Base class for all exceptions raised by this module.N)Ú__name__Ú __module__Ú __qualname__Ú__doc__©rrú&/opt/python35/lib/python3.5/smtplib.pyrGs c@seZdZdZdS)ÚSMTPNotSupportedErrorzÌThe command or option is not supported by the SMTP server. This exception is raised when an attempt is made to run a command or a command with an option which is not supported by the server. N)rrrrrrrrrJs rc@seZdZdZdS)rzÌNot connected to any SMTP server. This exception is raised when the server unexpectedly disconnects, or when an attempt is made to use the SMTP instance before connecting it to a server. N)rrrrrrrrrQs c@s"eZdZdZdd„ZdS)ra2Base class for all exceptions that include an SMTP error code. These exceptions are generated in some instances when the SMTP server returns an error code. The error code is stored in the `smtp_code' attribute of the error, and the `smtp_error' attribute is set to the error message. cCs%||_||_||f|_dS)N)Ú smtp_codeÚ smtp_errorÚargs)ÚselfÚcodeÚmsgrrrÚ__init__bs  zSMTPResponseException.__init__N)rrrrrrrrrrYs c@s"eZdZdZdd„ZdS)rz«Sender address refused. In addition to the attributes set by on all SMTPResponseException exceptions, this sets `sender' to the string that the SMTP refused. cCs1||_||_||_|||f|_dS)N)rrÚsenderr)rrrrrrrrns   zSMTPSenderRefused.__init__N)rrrrrrrrrrgs c@s"eZdZdZdd„ZdS)rzÎAll recipient addresses refused. The errors for each recipient are accessible through the attribute 'recipients', which is a dictionary of exactly the same sort as SMTP.sendmail() returns. cCs||_|f|_dS)N)Ú recipientsr)rrrrrr|s zSMTPRecipientsRefused.__init__N)rrrrrrrrrrts c@seZdZdZdS)rz'The SMTP server didn't accept the data.N)rrrrrrrrr�s c@seZdZdZdS)r z&Error during connection establishment.N)rrrrrrrrr „s c@seZdZdZdS)r z"The server refused our HELO reply.N)rrrrrrrrr ‡s c@seZdZdZdS)r zvAuthentication error. Most probably the server didn't accept the username/password combination provided. N)rrrrrrrrr Šs cCsStjj|ƒ\}}||fdkrK|jƒjdƒrC|Sd|Sd|S)z‡Quote a subset of the email addresses defined by RFC 821. Should be able to handle anything email.utils.parseaddr can handle. Úú)r r )ÚemailÚutilsÚ parseaddrÚstripÚ startswith)Ú addrstringÚ displaynameÚaddrrrrr ‘s cCs2tjj|ƒ\}}||fdkr.|S|S)Nr )r r )r"r#r$)r'r(r)rrrÚ _addr_onlyžsr*cCs"tjddtjdt|ƒƒS)z�Quote data for email. Double leading '.', and change Unix newline '\n', or Mac '\r' into Internet CRLF end-of-line. z(?m)^\.z..z(?:\r\n|\n|\r(?!\n)))ÚreÚsubÚCRLF)Údatarrrr ¦s cCstjdd|ƒS)Ns(?m)^\.s..)r+r,)ZbindatarrrÚ_quote_periods¯sr/cCstjdt|ƒS)Nz(?:\r\n|\n|\r(?!\n)))r+r,r-)r.rrrÚ _fix_eols²sr0FTc@s>eZdZdZdZdZdZdZdZdZ e Z ddde j ddd„Zdd „Zd d „Zd d „Zdd„Zdd„Zddddd„Zdd„Zddd„Zdd„Zddd„Zddd„Zddd „Zd!d"„Zdd#d$„Zd%d&„Zd'd(„Zd)d*„Zgd+d,„Z gd-d.„Z!d/d0„Z"d1d2„Z#e#Z$d3d4„Z%d5d6„Z&d7d8d9d:„Z'dd;d<„Z(dd=d>„Z)dd?d@„Z*d7d8dAdB„Z+ddddCdD„Z,ggdEdF„Z-ddgidGdH„Z.dIdJ„Z/dKdL„Z0dS)Mra´This class manages a connection to an SMTP or ESMTP server. SMTP Objects: SMTP objects have the following attributes: helo_resp This is the message given by the server in response to the most recent HELO command. ehlo_resp This is the message given by the server in response to the most recent EHLO command. This is usually multiline. does_esmtp This is a True value _after you do an EHLO command_, if the server supports ESMTP. esmtp_features This is a dictionary, which, if the server supports ESMTP, will _after you do an EHLO command_, contain the names of the SMTP service extensions this server supports, and their parameters (if any). Note, all extension names are mapped to lower case in the dictionary. See each method's docstrings for details. In general, there is a method of the same name to perform each SMTP command. There is also a method called 'sendmail' that will do an entire mail transaction. rNÚehlor c Csô||_||_i|_d|_||_|rp|j||ƒ\}}|dkrp|jƒt||ƒ‚|dk rˆ||_nht j ƒ}d|kr¬||_nDd} yt j t j ƒƒ} Wnt j k râYnXd| |_dS)aInitialize a new instance. If specified, `host' is the name of the remote host to which to connect. If specified, `port' specifies the port to which to connect. By default, smtplib.SMTP_PORT is used. If a host is specified the connect method is called, and if it returns anything other than a success code an SMTPConnectError is raised. If specified, `local_hostname` is used as the FQDN of the local host in the HELO/EHLO command. Otherwise, the local hostname is found using socket.getfqdn(). The `source_address` parameter takes a 2-tuple (host, port) for the socket to bind to as its source address before connecting. If the host is '' and port is 0, the OS default behavior will be used. ÚasciiéÜNÚ.z 127.0.0.1z[%s])Ú_hostÚtimeoutÚesmtp_featuresÚcommand_encodingÚsource_addressÚconnectÚcloser Úlocal_hostnameÚsocketÚgetfqdnÚ gethostbynameÚ gethostnameÚgaierror) rÚhostÚportr<r6r9rrZfqdnr)rrrrâs*            z SMTP.__init__cCs|S)Nr)rrrrÚ __enter__szSMTP.__enter__cGs_zMy4|jdƒ\}}|dkr6t||ƒ‚Wntk rKYnXWd|jƒXdS)NZQUITéÝ)Údocmdrrr;)rrrÚmessagerrrÚ__exit__s   z SMTP.__exit__cCs ||_dS)z¬Set the debug output level. A non-false value results in debug messages for connection and for all messages sent to and received from the server. N)Ú debuglevel)rrIrrrÚset_debuglevelszSMTP.set_debuglevelcGsN|jdkr7ttjjƒjƒ|dtjŒnt|dtjŒdS)NéÚfile)rIÚprintÚdatetimeZnowÚtimeÚsysÚstderr)rrrrrÚ _print_debug's(zSMTP._print_debugcCsG|jdkr+|jd||f|jƒtj||f||jƒS)Nrz connect: to)rIrRr9r=Úcreate_connection)rrBrCr6rrrÚ _get_socket-szSMTP._get_socketÚ localhostc Cs>|r||_| r¥|jdƒ|jdƒkr¥|jdƒ}|dkr¥|d|…||dd…}}yt|ƒ}Wntk r¤tdƒ‚YnX|s´|j}|jdkrÙ|jd||fƒ|j |||j ƒ|_ d|_ |j ƒ\}}|jdkr4|jdt|ƒƒ||fS)apConnect to a host on a given port. If the hostname ends with a colon (`:') followed by a number, and there is no port specified, that suffix will be stripped off and the number interpreted as the port number to use. Note: This method is automatically invoked by __init__, if a host is specified during instantiation. ú:rNrKznonnumeric portzconnect:)r9ÚfindÚrfindÚintÚ ValueErrorÚOSErrorÚ default_portrIrRrTr6ÚsockrLÚgetreplyÚrepr)rrBrCr9Úirrrrrr:5s(  % %   z SMTP.connectc Cs°|jdkr%|jdt|ƒƒt|dƒr |jr t|tƒr^|j|jƒ}y|jj |ƒWq¬t k rœ|j ƒt dƒ‚Yq¬Xn t dƒ‚dS)zSend `s' to the server.rzsend:r]zServer not connectedzplease run connect() firstN) rIrRr_Úhasattrr]Ú isinstanceÚstrÚencoder8Úsendallr[r;r)rÚsrrrÚsendWs  z SMTP.sendcCsC|dkrd|tf}nd||tf}|j|ƒdS)zSend a command to the server.r z%s%sz%s %s%sN)r-rg)rÚcmdrrcrrrÚputcmdis z SMTP.putcmdcCs±g}|jdkr*|jjdƒ|_xEy|jjtdƒ}WnEtk rŽ}z%|jƒtdt|ƒƒ‚WYdd}~XnX|s«|jƒtdƒ‚|j dkrÐ|j dt |ƒƒt |ƒtkrû|jƒt dd ƒ‚|j|d d…jd ƒƒ|dd …}yt|ƒ}Wntk rVd}PYnX|d d …d kr-Pq-Wdj|ƒ}|j dkr§|j d||fƒ||fS)a¨Get a reply from the server. Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) Note: returns -1 if it can't read response code. - server response string corresponding to response code (multiline responses are converted to a single, multiline string). Raises SMTPServerDisconnected if end-of-file is reached. NÚrbrKz Connection unexpectedly closed: zConnection unexpectedly closedrzreply:iôzLine too long.és éó-s zreply: retcode (%s); Msg: %aéÿÿÿÿ)rLr]ÚmakefileÚreadlineÚ_MAXLINEr[r;rrcrIrRr_ÚlenrÚappendr%rYrZÚjoin)rÚrespÚlineÚerZerrcodeÚerrmsgrrrr^qs>  #     z SMTP.getreplycCs|j||ƒ|jƒS)z-Send a command, and return its response code.)rir^)rrhrrrrrF¢sz SMTP.docmdcCs>|jd|p|jƒ|jƒ\}}||_||fS)zwSMTP 'helo' command. Hostname to send for this command defaults to the FQDN of the local host. Úhelo)rir<r^Ú helo_resp)rÚnamerrrrrry¨s z SMTP.heloc CsÏi|_|j|j|p!|jƒ|jƒ\}}|d krkt|ƒdkrk|jƒtdƒ‚||_|dkrŠ||fSd|_ t |jt ƒsºt t |jƒƒ‚|jjdƒjdƒ}|d=xæ|D]Þ}tj|ƒ}|r2|jjddƒd |jdƒd|jd[A-Za-z0-9][A-Za-z0-9\-]*) ?ÚfeatureNrn)r7riÚehlo_msgr<r^rrr;rÚ ehlo_respÚ does_esmtprbÚbytesÚAssertionErrorr_ÚdecodeÚsplitÚ OLDSTYLE_AUTHÚmatchÚgetÚgroupsr+ÚgroupÚlowerÚstringÚendr%) rr{rrruÚeachZ auth_matchÚmr€Úparamsrrrr1²s4       ' 1" 'z SMTP.ehlocCs|jƒ|jkS)z7Does the server support a given SMTP service extension?)r�r7)rÚoptrrrÚhas_extnåsz SMTP.has_extncCs|jd|ƒ|jƒdS)z;SMTP 'help' command. Returns help text from server.ÚhelprK)rir^)rrrrrr•ész SMTP.helpcCsd|_|jdƒS)z&SMTP 'rset' command -- resets session.r2Úrset)r8rF)rrrrr–ïs z SMTP.rsetc Cs'y|jƒWntk r"YnXdS)aInternal 'rset' command which ignores any SMTPServerDisconnected error. Used internally in the library, since the server disconnected error should appear to the application when the *next* command is issued, if we are doing an internal "safety" reset. N)r–r)rrrrÚ_rsetôs z SMTP._rsetcCs |jdƒS)z-SMTP 'noop' command -- doesn't do anything :>Únoop)rF)rrrrr˜sz SMTP.noopcCs’d}|rh|jrhtdd„|DƒƒrU|jdƒrId|_n tdƒ‚ddj|ƒ}|jdd t|ƒ|fƒ|jƒS) a8SMTP 'mail' command -- begins mail xfer session. This method may raise the following exceptions: SMTPNotSupportedError The options parameter includes 'SMTPUTF8' but the SMTPUTF8 extension is not supported by the server. r css!|]}|jƒdkVqdS)Úsmtputf8N)r�)Ú.0Úxrrrú szSMTP.mail..r™zutf-8z SMTPUTF8 not supported by serverrÚmailz FROM:%s%s) rƒÚanyr”r8rrtrir r^)rrÚoptionsÚ optionlistrrrr�s    z SMTP.mailcCsRd}|r(|jr(ddj|ƒ}|jddt|ƒ|fƒ|jƒS)z;SMTP 'rcpt' command -- indicates 1 recipient for this mail.r rÚrcptzTO:%s%s)rƒrtrir r^)rZreciprŸr rrrr¡s  z SMTP.rcptcCs|jdƒ|jƒ\}}|jdkrD|jd||fƒ|dkrbt||ƒ‚n¬t|tƒr†t|ƒjdƒ}t |ƒ}|d d…t kr²|t }|dt }|j |ƒ|jƒ\}}|jdkr|jd||fƒ||fSdS) aÚSMTP 'DATA' command -- sends message data to server. Automatically quotes lines beginning with a period per rfc821. Raises SMTPDataError if there is an unexpected reply to the DATA command; the return value from this method is the final response code received when the all data is sent. If msg is a string, lone '\r' and '\n' characters are converted to '\r\n' characters. If msg is bytes, it is transmitted as is. r.rzdata:ibr2éNó.éþÿÿÿ) rir^rIrRrrbrcr0rdr/ÚbCRLFrg)rrrÚreplÚqrrrr.!s"     z SMTP.datacCs |jdt|ƒƒ|jƒS)z5SMTP 'verify' command -- checks for address validity.Úvrfy)rir*r^)rÚaddressrrrÚverify>sz SMTP.verifycCs |jdt|ƒƒ|jƒS)z.SMTP 'expn' command -- expands a mailing list.Úexpn)rir*r^)rr©rrrr«Esz SMTP.expncCs…|jdkr�|jdkr�d|jƒdko?dkns�|jƒ\}}d|komdkns�t||ƒ‚dS)abCall self.ehlo() and/or self.helo() if needed. If there has been no previous EHLO or HELO command this session, this method tries ESMTP EHLO first. This method may raise the following exceptions: SMTPHeloError The server didn't reply properly to the helo greeting. NéÈri+)rzr‚r1ryr )rrrurrrÚehlo_or_helo_if_neededLs &zSMTP.ehlo_or_helo_if_neededÚinitial_response_okTc Csý|jƒ}|r|ƒnd}|dk rkt|jdƒddƒ}|jd|d|ƒ\}}n|jd|ƒ\}}|dkrÔtj|ƒ}t||ƒjdƒddƒ}|j|ƒ\}}|d krê||fSt||ƒ‚dS) aøAuthentication command - requires response processing. 'mechanism' specifies which authentication mechanism is to be used - the valid values are those listed in the 'auth' element of 'esmtp_features'. 'authobject' must be a callable object taking a single argument: data = authobject(challenge) It will be called to process the server's challenge response; the challenge argument it is passed will be a bytes. It should return bytes data that will be base64 encoded and sent to the server. Keyword arguments: - initial_response_ok: Allow sending the RFC 4954 initial-response to the AUTH command, if the authentication methods supports it. Nr2Zeolr ZAUTHriNéëé÷)r¯r°)ÚupperÚ encode_base64rdrFÚbase64Z decodebytesr ) rZ mechanismZ authobjectr®Zinitial_responseÚresponserruÚ challengerrrr~]s  #   z SMTP.authcCs@|dkrdS|jdtj|jjdƒ|dƒjƒS)zh Authobject to use with CRAM-MD5 authentication. Requires self.user and self.password to be set.Nrr2Úmd5)ÚuserÚhmacZHMACÚpasswordrdÚ hexdigest)rrµrrrÚ auth_cram_md5„s zSMTP.auth_cram_md5cCsd|j|jfS)ze Authobject to use with PLAIN authentication. Requires self.user and self.password to be set.z%s%s)r·r¹)rrµrrrÚ auth_plain�szSMTP.auth_plaincCs|dkr|jS|jSdS)ze Authobject to use with LOGIN authentication. Requires self.user and self.password to be set.N)r·r¹)rrµrrrÚ auth_login’s zSMTP.auth_loginc s+|jƒ|jdƒs%tdƒ‚|jdjƒ‰dddg}‡fdd†|Dƒ}|srtdƒ‚|||_|_x™|D]‘}d |jƒj d d ƒ}yA|j |t ||ƒd |ƒ\}} |dkrî|| fSWqŒt k r} z | } WYdd} ~ XqŒXqŒW| ‚dS)awLog in on an SMTP server that requires authentication. The arguments are: - user: The user name to authenticate with. - password: The password for the authentication. Keyword arguments: - initial_response_ok: Allow sending the RFC 4954 initial-response to the AUTH command, if the authentication methods supports it. If there has been no previous EHLO or HELO command this session, this method tries ESMTP EHLO first. This method will return normally if the authentication was successful. This method may raise the following exceptions: SMTPHeloError The server didn't reply properly to the helo greeting. SMTPAuthenticationError The server didn't accept the username/ password combination. SMTPNotSupportedError The AUTH command is not supported by the server. SMTPException No suitable authentication method was found. r~z,SMTP AUTH extension not supported by server.zCRAM-MD5ZPLAINZLOGINcs"g|]}|ˆkr|‘qSrr)ršr~)Úadvertised_authlistrrú Ãs zSMTP.login..z(No suitable authentication method found.Zauth_ú-Ú_r®r¯é÷N)r¯rÂ) r­r”rr7r‡rr·r¹r�Úreplacer~Úgetattrr ) rr·r¹r®Zpreferred_authsZauthlistZ authmethodZ method_namerrurwZlast_exceptionr)r¾rÚloginšs*     z SMTP.logincCs+|jƒ|jdƒs%tdƒ‚|jdƒ\}}|dkrtsXtdƒ‚|dk r||dk r|tdƒ‚|dk r |dk r tdƒ‚|dkrÄtjd |d |ƒ}|j |j d |j ƒ|_ d|_ d|_ d|_i|_d |_nt||ƒ‚||fS) a¡Puts the connection to the SMTP server into TLS mode. If there has been no previous EHLO or HELO command this session, this method tries ESMTP EHLO first. If the server supports TLS, this will encrypt the rest of the SMTP session. If you provide the keyfile and certfile parameters, the identity of the SMTP server and client can be checked. This, however, depends on whether the socket module really checks the certificates. This method may raise the following exceptions: SMTPHeloError The server didn't reply properly to the helo greeting. Ústarttlsz+STARTTLS extension not supported by server.ZSTARTTLSr3z&No SSL support included in this PythonNz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusiveÚcertfileÚkeyfileÚserver_hostnamer)r­r”rrFÚ _have_sslÚ RuntimeErrorrZÚsslÚ_create_stdlib_contextÚ wrap_socketr]r5rLrzr‚r7rƒr)rrÈrÇÚcontextruZreplyrrrrÆÜs0             z SMTP.starttlsc Csð|jƒg}t|tƒr4t|ƒjdƒ}|jr�|jdƒrc|jdt|ƒƒx|D]}|j|ƒqjW|j ||ƒ\}} |dkrÚ|dkr¾|j ƒn |j ƒt || |ƒ‚i} t|tƒrø|g}xp|D]h} |j | |ƒ\}} |dkrE|dkrE|| f| | <|dkrÿ|j ƒt| ƒ‚qÿWt| ƒt|ƒkr™|j ƒt| ƒ‚|j|ƒ\}} |dkrì|dkrÓ|j ƒn |j ƒt|| ƒ‚| S)a| This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : A list of addresses to send this mail to. A bare string will be treated as a list with 1 address. - msg : The message to send. - mail_options : List of ESMTP options (such as 8bitmime) for the mail command. - rcpt_options : List of ESMTP options (such as DSN commands) for all the rcpt commands. msg may be a string containing characters in the ASCII range, or a byte string. A string is encoded to bytes using the ascii codec, and lone \r and \n characters are converted to \r\n characters. If there has been no previous EHLO or HELO command this session, this method tries ESMTP EHLO first. If the server does ESMTP, message size and each of the specified options will be passed to it. If EHLO fails, HELO will be tried and ESMTP options suppressed. This method will return normally if the mail is accepted for at least one recipient. It returns a dictionary, with one entry for each recipient that was refused. Each entry contains a tuple of the SMTP error code and the accompanying error message sent by the server. This method may raise the following exceptions: SMTPHeloError The server didn't reply properly to the helo greeting. SMTPRecipientsRefused The server rejected ALL recipients (no mail was sent). SMTPSenderRefused The server didn't accept the from_addr. SMTPDataError The server replied with an unexpected error code (other than a refusal of a recipient). SMTPNotSupportedError The mail_options parameter includes 'SMTPUTF8' but the SMTPUTF8 extension is not supported by the server. Note: the connection will be open even after an exception is raised. Example: >>> import smtplib >>> s=smtplib.SMTP("localhost") >>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"] >>> msg = '''\ ... From: Me@my.org ... Subject: testin'... ... ... This is a test ''' >>> s.sendmail("me@my.org",tolist,msg) { "three@three.org" : ( 550 ,"User unknown" ) } >>> s.quit() In the above example, the message was accepted for delivery to three of the four addresses, and one was rejected, with the error code 550. If all addresses are accepted, then the method will return an empty dictionary. r2Úsizezsize=%dr|i¥éû)r­rbrcr0rdrƒr”rsrrr�r;r—rr¡rr.r) rÚ from_addrÚto_addrsrÚ mail_optionsÚ rcpt_optionsZ esmtp_optsÚoptionrruZsenderrsr�rrrÚsendmailsF@                 z SMTP.sendmailcCs|jƒ|jdƒ}|dkr.d}n't|ƒdkrId}n tdƒ‚|dkr�|d|kr||dn ||d}|dkrìd d „||d ||d ||d fDƒ}dd „tjj|ƒDƒ}tj|ƒ} | d =| d=d} y#dj|f|•ƒj dƒWn3t k rg|j dƒs]t dƒ‚d} YnXt jƒ�x} | r·tjj| d|jjddƒƒ} |ddg7}ntjj| ƒ} | j| ddƒ| jƒ} WdQRX|j||| ||ƒS)a~Converts message to a bytestring and passes it to sendmail. The arguments are as for sendmail, except that msg is an email.message.Message object. If from_addr is None or to_addrs is None, these arguments are taken from the headers of the Message as described in RFC 2822 (a ValueError is raised if there is more than one set of 'Resent-' headers). Regardless of the values of from_addr and to_addr, any Bcc field (or Resent-Bcc field, when the Message is a resent) of the Message object won't be transmitted. The Message object is then serialized using email.generator.BytesGenerator and sendmail is called to transmit the message. If the sender or any of the recipient addresses contain non-ASCII and the server advertises the SMTPUTF8 capability, the policy is cloned with utf8 set to True for the serialization, and SMTPUTF8 and BODY=8BITMIME are asserted on the send. If the server does not support SMTPUTF8, an SMTPNotSupported error is raised. Otherwise the generator is called without modifying the policy. z Resent-DateNr rKzResent-z0message has more than one 'Resent-' header blockZSenderÚFromcSs"g|]}|dk r|‘qS)Nr)ršÚfrrrr¿¥s z%SMTP.send_message..ÚToZBccZCccSsg|]}|d‘qS)rKr)ršÚarrrr¿©s z Resent-BccFr2r™z”One or more source or delivery addresses require internationalized email support, but the server does not advertise the required SMTPUTF8 capabilityTÚpolicyÚutf8ZSMTPUTF8z BODY=8BITMIMEÚlinesepz )r­Zget_allrrrZr"r#Z getaddressesÚcopyrtrdÚUnicodeEncodeErrorr”rÚioÚBytesIOÚ generatorZBytesGeneratorrÜZcloneZflattenÚgetvaluer×)rrrÒrÓrÔrÕZresentZ header_prefixZ addr_fieldsZmsg_copyÚ internationalZbytesmsgÚgZflatmsgrrrÚ send_messagexsH        #    zSMTP.send_messagec CsPz&|j}d|_|r%|jƒWd|j}d|_|rK|jƒXdS)z(Close the connection to the SMTP server.N)rLr;r])rrLr]rrrr;Äs    z SMTP.closecCs?|jdƒ}d|_|_i|_d|_|jƒ|S)zTerminate the SMTP session.ÚquitNF)rFr‚rzr7rƒr;)rÚresrrrrèÑs    z SMTP.quit)1rrrrrIrLrzr�r‚rƒÚ SMTP_PORTr\r=Ú_GLOBAL_DEFAULT_TIMEOUTrrDrHrJrRrTr:rgrir^rFryr1r”r•r–r—r˜r�r¡r.rªr¨r«r­r~r»r¼r½rÅrÆr×rçr;rèrrrrr½s^  -   "  1 3       ' B4gK c @sOeZdZdZeZdddddejdddd„Zdd„Z dS) ÚSMTP_SSLaé This is a subclass derived from SMTP that connects over an SSL encrypted socket (to use this class you need a socket module that was compiled with SSL support). If host is not specified, '' (the local host) is used. If port is omitted, the standard SMTP-over-SSL port (465) is used. local_hostname and source_address have the same meaning as they do in the SMTP class. keyfile and certfile are also optional - they can contain a PEM formatted private key and certificate chain file for the SSL connection. context also optional, can contain a SSLContext, and is an alternative to keyfile and certfile; If it is specified both keyfile and certfile must be None. r rNc Cs§|dk r$|dk r$tdƒ‚|dk rH|dk rHtdƒ‚||_||_|dkr~tjd|d|ƒ}||_tj||||||ƒdS)Nz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusiverÇrÈ)rZrÈrÇrÌrÍrÏrr) rrBrCr<rÈrÇr6r9rÏrrrrís       zSMTP_SSL.__init__cCsb|jdkr%|jd||fƒtj||f||jƒ}|jj|d|jƒ}|S)Nrzconnect:rÉ)rIrRr=rSr9rÏrÎr5)rrBrCr6Z new_socketrrrrTs  zSMTP_SSL._get_socket) rrrrÚ SMTP_SSL_PORTr\r=rërrTrrrrrìÝs  rìiÓc@sIeZdZdZdZdedddd„Zdddd d „ZdS) ÚLMTPa‰LMTP - Local Mail Transfer Protocol The LMTP protocol, which is very similar to ESMTP, is heavily based on the standard SMTP client. It's common to use Unix sockets for LMTP, so our connect() method must support that as well as a regular host:port server. local_hostname and source_address have the same meaning as they do in the SMTP class. To specify a Unix socket, you must use an absolute path as the host, starting with a '/'. Authentication is supported, using the regular SMTP mechanism. When using a Unix socket, LMTP generally don't support or require any authentication, but your mileage might vary.Zlhlor NcCs#tj|||d|d|ƒdS)zInitialize a new instance.r<r9N)rr)rrBrCr<r9rrrr sz LMTP.__init__rUrc Csò|ddkr)tj|||d|ƒSy8tjtjtjƒ|_d|_|jj|ƒWnStk r¶|jdkr�|j d|ƒ|jr¦|jj ƒd|_‚YnX|j ƒ\}}|jdkrè|j d|ƒ||fS)z=Connect to the LMTP daemon, on either a Unix or a TCP socket.rú/r9Nz connect fail:zconnect:) rr:r=ÚAF_UNIXÚ SOCK_STREAMr]rLr[rIrRr;r^)rrBrCr9rrrrrr:&s"     z LMTP.connect)rrrrr�Ú LMTP_PORTrr:rrrrrîs  rîÚ__main__cCs4tjj|dƒtjjƒtjjƒjƒS)Nz: )rPÚstdoutÚwriteÚflushÚstdinrpr%)Úpromptrrrrø@s rørØrÚú,zEnter message, end with ^D:r zMessage length is %drUrK)@rr=rár+Z email.utilsr"Z email.messageZemail.generatorr³r¸rßrNrPZemail.base64mimerr²Ú__all__rêrír-r¥rqÚcompileÚIrˆr[rrrrrrrr r r r r*r r/r0rÌÚ ImportErrorrÊrrìrsròrîrrøZfromaddrr‡ZtoaddrsrMrr÷rprvrrZserverrJr×rèrrrrÚ!s†                     ÿÿÿ!, /