rajeevs1992

confMail.py

Sep 25th, 2011
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.40 KB | None | 0 0
  1. import smtplib
  2. import string
  3. import MySQLdb
  4. from email.MIMEMultipart import MIMEMultipart
  5. from email.MIMEText import MIMEText
  6. import randPass #the code for this module is available at http://pastebin.com/8GxjYcrX
  7. handle=MIMEMultipart()
  8. handle["From"]="[email protected]"
  9. handle["Subject"]=" Confirmation Email from  <GEC Git Repo> "
  10. db = MySQLdb.connect(host="localhost",user="<>",passwd="<>",db="<>")
  11. cursor=db.cursor()
  12. server = smtplib.SMTP("smtp.gmail.com:587")
  13. server.starttls()
  14. server.login("[email protected]","<passwd>")
  15.  
  16. query="select * from Accounts"
  17. cursor.execute(query)
  18. row=cursor.fetchone()
  19. while row:
  20.     randword=randPass.gen()
  21.     query=" update Accounts set passwd=SHA('"+randword+"') "
  22.     cursor.execute(query)
  23.     handle["To"]=row[3]
  24.     message=''' This is a computer generated Email.Please note That reply to this address may not be monitered
  25.               You have received this mail  as you have requested for confirmation code  of GEC GitRepository.
  26.  
  27.            Here are your account details:
  28.            Username          : ''' + row[0] +'''
  29.            Confirmation Code : ''' + randword + '''
  30.            
  31.  
  32.            if you have no idea what is happening , please ignore this mail
  33.            Some body might have entered your Mail Id by mistake. '''
  34.    
  35.     handle.attach(MIMEText(message))
  36.     server.sendmail("[email protected]",row[3],handle.as_string())
  37.     row = cursor.fetchone()
  38.  
  39. server.quit()
Advertisement
Add Comment
Please, Sign In to add comment