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 |
How do you write comments in python?
What is a namedtuple?
What is abnormal termination?
What is type() and id() will do?
Explain about zip() in python?
How do you check if a list is empty in python?
Should I learn r or python first?
What is import time in python?
How to remove values to a python array?
What is set () in python?
What is the output of this below query?
If given the first and last names of bunch of employees how would you store it and what datatype?