# from smtplib import SMTP # For sending without SSL/TLS.
from smtplib import SMTP_SSL
server = 'blackhole.io' # Change this to your server address.
msg = '''From: <[email protected]>
To: <[email protected]>
Subject: Test email
Random test email. Some UTF-8 characters: ßæøþ'''
# smtp = SMTP(server, 25) # For sending without SSL/TLS.
smtp = SMTP_SSL(server, 465)
smtp.sendmail('[email protected]', '[email protected]',
msg.encode('utf-8'))
# We can send multiple messages using the same connection.
smtp.sendmail(server, '[email protected]',
msg.encode('utf-8'))
# Quit after we're done
smtp.quit()
DATA
>>> DATA
354 End data with <CR><LF>.<CR><LF>
>>> some email content
>>> .
EHLO domain.tld
>>> EHLO domain.tld
250-blackhole.io
250-HELP
250-PIPELINING
250-AUTH CRAM-MD5 LOGIN PLAIN
250-SIZE
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-SMTPUTF8
250 DSN
ETRN
>>> ETRN
250 Queueing started
HELO domain.tld
>>> HELO domain.tld
250 OK
HELP
COMMAND
>>> HELP
250 Supported commands: AUTH DATA EHLO ETRN HELO MAIL NOOP QUIT RCPT RSET
VRFY
>>> HELP AUTH
250 Syntax: AUTH CRAM-MD5 LOGIN PLAIN
MAIL FROM: <user@domain.tld>
BODY= 7BIT, 8BITMIME
SMTPUTF8
SIZE= SIZE
>>> MAIL FROM: <test@domain.tld>
250 2.1.0 OK
>>> MAIL FROM: <test@domain.tld> BODY=7BIT
250 2.1.0 OK
>>> MAIL FROM: <test@domain.tld> BODY=8BITMIME
250 2.1.0 OK
>>> MAIL FROM: <test@domain.tld> SMTPUTF8
250 2.1.0 OK
You can also specify the size using the SIZE=
parameter.
>>> MAIL FROM: <test@domain.tld> SIZE=82000
250 2.1.0 OK
NOOP
>>> NOOP
250 2.0.0 OK
QUIT
>>> QUIT
221 2.0.0 Goodbye
RCPT TO: <user@domain.tld>
>>> RCPT TO: <test@domain.tld>
250 2.1.0 OK
RSET
>>> RSET
250 2.0.0 OK
250: 2.0.0 OK: queued as MESSAGE-ID
450: Requested mail action not taken: mailbox unavailable
451: Requested action aborted: local error in processing
452: Requested action not taken: insufficient system storage
458: Unable to queue message
521: Machine does not accept mail
550: Requested action not taken: mailbox unavailable
551: User not local
552: Requested mail action aborted: exceeded storage allocation
553: Requested action not taken: mailbox name not allowed
571: Blocked