Share Pastebin
Guest
Public paste!

goobsoft

By: a guest | Oct 19th, 2008 | Syntax: Python | Size: 0.99 KB | Hits: 89 | Expires: Never
Copy text to clipboard
  1. # Upload Images to SmugMug
  2.  
  3. import smtplib
  4. import os
  5. import sys
  6. from email.MIMEMultipart import MIMEMultipart
  7. from email.MIMEText import MIMEText
  8. from email.MIMEImage import MIMEImage
  9.  
  10.  
  11. for root, dirs, files in os.walk('.'):
  12.     for filename in files:
  13.         msg = MIMEMultipart()
  14.         msg['From'] = 'accout@gmail.com'
  15.         msg['To'] = 'user@email.smugmug.com'
  16.         msg['Subject'] = 'password'
  17.        
  18.         attach = MIMEImage(file(os.path.join(root, filename)).read())
  19.         # SmugMug Requires a fileName
  20.         attach.add_header('Content-Disposition', 'attachment', filename=filename)
  21.         msg.attach(attach)
  22.        
  23.         print "Sending %s." % filename,
  24.        
  25.         server = smtplib.SMTP('email.smugmug.com')
  26.         #server.set_debuglevel(1)
  27.  
  28.         # Must use as_string for it to work right
  29.         server.sendmail("account@gmail.com", "user@email.smugmug.com", msg.as_string())
  30.         server.quit()
  31.        
  32.         print "Sent"
  33.         #sys.exit(1)