Describe how to send mail from a Python script.
Answer / chaitanya
The smtplib module defines an SMTP client session object that can be used to send mail to any Internet machine.
A sample email is demonstrated below.
import smtplib
SERVER = smtplib.SMTP(‘smtp.server.domain’)
FROM = sender@mail.com
TO = ["user@mail.com"] # must be a list
SUBJECT = "Hello!"
TEXT = "This message was sent with Python's smtplib."
# Main message
message = """
From: Sarah Naaz < sender@mail.com >
To: CarreerRide user@mail.com
Subject: SMTP email msg
This is a test email. Acknowledge the email by responding.
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
server = smtplib.SMTP(SERVER)
server.sendmail(FROM, TO, message)
server.quit()
| Is This Answer Correct ? | 0 Yes | 0 No |
please give the code for these 1 2 4 7 11 16...
What's the difference between list and tuples?
What is the output of this below query?
Explain me what is python and explain some of its benefits?
How to check the string consists of alphanumeric characters ?
Tell me what is the difference between django, pyramid, and flask?
Why does delegation performed in Python?
Is python a scripting or programming?
How the string does get converted to a number?
What is the best Django or PHP?
Can we concat bytes to str?
What is the difference between cpython and python?