Posted by Chad on Sat 21 Feb 21:26 (modification of post by goobsoft view diff)
report abuse | download | new post
- # Upload Images to SmugMug
- import smtplib
- import os
- import sys
- from email.MIMEMultipart import MIMEMultipart
- from email.MIMEText import MIMEText
- from email.MIMEImage import MIMEImage
- for root, dirs, files in os.walk('.'):
- for filename in files:
- if filename[-4:] == ".jpg":
- print filename
- msg = MIMEMultipart()
- msg['From'] = 'me@gmail.com'
- msg['To'] = 'sasds@email.smugmug.com'
- msg['Subject'] = 'swing'
- attach = MIMEImage(file(os.path.join(root, filename)).read())
- # SmugMug Requires a fileName
- attach.add_header('Content-Disposition', 'attachment', filename=filename)
- msg.attach(attach)
- print "Sending %s." % filename,
- server = smtplib.SMTP('email.smugmug.com')
- #server.set_debuglevel(1)
- # Must use as_string for it to work right
- server.sendmail(msg['From'], msg['To'], msg.as_string())
- server.quit()
- print "Sent"
- #sys.exit(1)
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.