parameters: (self, from_addr, to_addrs, msg, mail_options=(),
                   rcpt_options=())
return_statement: return senderrs
docstring: 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.
docstring_summary: This command performs an entire mail transaction.
docstring_tokens: This command performs an entire mail transaction .
function: def sendmail(self, from_addr, to_addrs, msg, mail_options=(),
                   rcpt_options=()):
          """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.
  
          """
          self.ehlo_or_helo_if_needed()
          esmtp_opts = []
          if isinstance(msg, str):
              msg = _fix_eols(msg).encode('ascii')
          if self.does_esmtp:
              if self.has_extn('size'):
                  esmtp_opts.append("size=%d" % len(msg))
              for option in mail_options:
                  esmtp_opts.append(option)
          (code, resp) = self.mail(from_addr, esmtp_opts)
          if code != 250:
              if code == 421:
                  self.close()
              else:
                  self._rset()
              raise SMTPSenderRefused(code, resp, from_addr)
          senderrs = {}
          if isinstance(to_addrs, str):
              to_addrs = [to_addrs]
          for each in to_addrs:
              (code, resp) = self.rcpt(each, rcpt_options)
              if (code != 250) and (code != 251):
                  senderrs[each] = (code, resp)
              if code == 421:
                  self.close()
                  raise SMTPRecipientsRefused(senderrs)
          if len(senderrs) == len(to_addrs):
              # the server refused all our recipients
              self._rset()
              raise SMTPRecipientsRefused(senderrs)
          (code, resp) = self.data(msg)
          if code != 250:
              if code == 421:
                  self.close()
              else:
                  self._rset()
              raise SMTPDataError(code, resp)
          #if we got here then somebody got our mail
          return senderrs
function_tokens: def sendmail ( self , from_addr , to_addrs , msg , mail_options = ( ) , rcpt_options = ( ) ) : self . ehlo_or_helo_if_needed ( ) esmtp_opts = [ ] if isinstance ( msg , str ) : msg = _fix_eols ( msg ) . encode ( 'ascii' ) if self . does_esmtp : if self . has_extn ( 'size' ) : esmtp_opts . append ( "size=%d" % len ( msg ) ) for option in mail_options : esmtp_opts . append ( option ) ( code , resp ) = self . mail ( from_addr , esmtp_opts ) if code != 250 : if code == 421 : self . close ( ) else : self . _rset ( ) raise SMTPSenderRefused ( code , resp , from_addr ) senderrs = { } if isinstance ( to_addrs , str ) : to_addrs = [ to_addrs ] for each in to_addrs : ( code , resp ) = self . rcpt ( each , rcpt_options ) if ( code != 250 ) and ( code != 251 ) : senderrs [ each ] = ( code , resp ) if code == 421 : self . close ( ) raise SMTPRecipientsRefused ( senderrs ) if len ( senderrs ) == len ( to_addrs ) : # the server refused all our recipients self . _rset ( ) raise SMTPRecipientsRefused ( senderrs ) ( code , resp ) = self . data ( msg ) if code != 250 : if code == 421 : self . close ( ) else : self . _rset ( ) raise SMTPDataError ( code , resp ) #if we got here then somebody got our mail return senderrs