MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / sendmail

Method sendmail

tools/python-3.11.9-amd64/Lib/smtplib.py:808–910  ·  view source on GitHub ↗

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.

(self, from_addr, to_addrs, msg, mail_options=(),
                 rcpt_options=())

Source from the content-addressed store, hash-verified

806 return (resp, reply)
807
808 def sendmail(self, from_addr, to_addrs, msg, mail_options=(),
809 rcpt_options=()):
810 """This command performs an entire mail transaction.
811
812 The arguments are:
813 - from_addr : The address sending this mail.
814 - to_addrs : A list of addresses to send this mail to. A bare
815 string will be treated as a list with 1 address.
816 - msg : The message to send.
817 - mail_options : List of ESMTP options (such as 8bitmime) for the
818 mail command.
819 - rcpt_options : List of ESMTP options (such as DSN commands) for
820 all the rcpt commands.
821
822 msg may be a string containing characters in the ASCII range, or a byte
823 string. A string is encoded to bytes using the ascii codec, and lone
824 \\r and \\n characters are converted to \\r\\n characters.
825
826 If there has been no previous EHLO or HELO command this session, this
827 method tries ESMTP EHLO first. If the server does ESMTP, message size
828 and each of the specified options will be passed to it. If EHLO
829 fails, HELO will be tried and ESMTP options suppressed.
830
831 This method will return normally if the mail is accepted for at least
832 one recipient. It returns a dictionary, with one entry for each
833 recipient that was refused. Each entry contains a tuple of the SMTP
834 error code and the accompanying error message sent by the server.
835
836 This method may raise the following exceptions:
837
838 SMTPHeloError The server didn't reply properly to
839 the helo greeting.
840 SMTPRecipientsRefused The server rejected ALL recipients
841 (no mail was sent).
842 SMTPSenderRefused The server didn't accept the from_addr.
843 SMTPDataError The server replied with an unexpected
844 error code (other than a refusal of
845 a recipient).
846 SMTPNotSupportedError The mail_options parameter includes 'SMTPUTF8'
847 but the SMTPUTF8 extension is not supported by
848 the server.
849
850 Note: the connection will be open even after an exception is raised.
851
852 Example:
853
854 >>> import smtplib
855 >>> s=smtplib.SMTP("localhost")
856 >>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"]
857 >>> msg = '''\\
858 ... From: Me@my.org
859 ... Subject: testin'...
860 ...
861 ... This is a test '''
862 >>> s.sendmail("me@my.org",tolist,msg)
863 { "three@three.org" : ( 550 ,"User unknown" ) }
864 >>> s.quit()
865

Callers 3

_deliverMethod · 0.95
send_messageMethod · 0.95
smtplib.pyFile · 0.80

Calls 13

has_extnMethod · 0.95
mailMethod · 0.95
closeMethod · 0.95
_rsetMethod · 0.95
rcptMethod · 0.95
dataMethod · 0.95
_fix_eolsFunction · 0.85
SMTPSenderRefusedClass · 0.85
SMTPDataErrorClass · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected