Created
          November 20, 2012 10:07 
        
      - 
      
- 
        Save xiaoyao1991/4117092 to your computer and use it in GitHub Desktop. 
    Sending email
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import smtplib | |
| sendto = ['[email protected]', '[email protected]', '[email protected]'] #收件人 | |
| no = [1,2,3] #编号 | |
| gmail_username = '[email protected]' | |
| gmail_password = 'password' | |
| smtpserver = smtplib.SMTP("smtp.gmail.com", 587) | |
| smtpserver.ehlo() | |
| smtpserver.starttls() | |
| smtpserver.ehlo() | |
| smtpserver.login(gmail_username,gmail_password) | |
| for i in range(len(sendto)): | |
| header = 'To:' + sendto[i] + 'From:' + gmail_username + '\n' + 'Subject:testing \n' | |
| print header | |
| msg = header + '\n this is testing if python gmail works \n\n' + str(no[i]) | |
| smtpserver.sendmail(gmail_username, sendto, msg) | |
| print 'done!' | |
| smtpserver.close() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment