Pages

Thursday, September 16, 2010

Sending E-Maill in Python with No Attachments

How t o send E-Mail in python with out any
attachments ??
Just have look on the code.



import smtplib       # --> Module Name
SERVER = "Your-SMTP-Server-IP"
try:

        FROM = "Your - Email ID"
        TO =  ["Recipients E-Mail ID"]

       
        SUBJECT = "subject"
        TEXT="text message"
        # Prepare actual message

        message = """\
        From: %s
        To: %s
        Subject: %s

        %s
        """ % (FROM, ", ".join(TO), SUBJECT, TEXT)

        # Send the mail

        server = smtplib.SMTP(SERVER)
        server.sendmail(FROM, TO, message)
        server.quit()
        msg="uploaded sucessfully"
    print msg
except Exception ,e :
  print "ERROR"

  print e

That 's it..

No comments:

Post a Comment