Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Describe how to send mail from a Python script.



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

Post New Answer

More Python Interview Questions

What is the purpose of bytes() in python?

0 Answers  


Explain the use of try: except raise, and finally?

0 Answers  


Explain the uses of the modules sqlite3, ctypes, pickle, traceback, and itertools.

0 Answers  


What is uuid format?

0 Answers  


How does Python handle the memory management?

0 Answers  


Do you always need a default constructor?

0 Answers  


What do you understand by *args and **kwarg python?

0 Answers  


Explain about assert statement?

0 Answers  


What are python namespaces?

0 Answers  


How to improve performance of this code?

0 Answers  


Does python have long?

0 Answers  


What is flask?

0 Answers  


Categories