pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Python pastebin - collaborative debugging tool View Help


Posted by Chad on Sat 21 Feb 21:26 (modification of post by goobsoft view diff)
report abuse | download | new post

  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.         if filename[-4:] == ".jpg":
  14.             print filename
  15.             msg = MIMEMultipart()
  16.             msg['From'] = 'me@gmail.com'
  17.             msg['To'] = 'sasds@email.smugmug.com'
  18.             msg['Subject'] = 'swing'
  19.  
  20.             attach = MIMEImage(file(os.path.join(root, filename)).read())
  21.             # SmugMug Requires a fileName
  22.             attach.add_header('Content-Disposition', 'attachment', filename=filename)
  23.             msg.attach(attach)
  24.  
  25.             print "Sending %s." % filename,
  26.  
  27.             server = smtplib.SMTP('email.smugmug.com')
  28.             #server.set_debuglevel(1)
  29.  
  30.             # Must use as_string for it to work right
  31.             server.sendmail(msg['From'], msg['To'], msg.as_string())
  32.             server.quit()
  33.  
  34.             print "Sent"
  35.             #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.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post