Below are a few code snippets I've written to send email from Python:
First is something to send an email from Python as formatted html. The example pulls the html from a web page, you could easily change that to a string or file.
Source code here.
The next script sends an email with a random jpeg attachment from a directory of pictures.
Source code here.
And finally the last script sends an email with an embedded image.
Source code here.
I needed to access my firms Exchange server. The only way I could get access was through webdav. I wrote a couple of Python modules, the first was to provide an easy way to send an XML request over HTTP. Originally I was using the Micorosfts XMLHTTP COM Object on WIndows, however I wanted my code to run on LINUX and Windows, hence the need for the XMLHTTP module.
The xmlhttp module is here.
I haven't covered all webdav commands in my webdav module, just the ones I needed to use. Theres a fairly good reference to Webdav on the Micorosft Website if you need to use other commands.
The webdav module can be found here.
Its my 40th birthday in December and as part of the celebrations, I wanted to have a party!
At the party I wanted to have music playing (nothing new there), a slight twist is that I thought it may be good to have music videos playing. The sort of music I wanted to play was 80's - Flock of Seagulls, Tears for Fears etc, etc and also some more modern stuff Greenday etc. One way to collect the videos might be to sit watching MTV and hit record whenever a clip comes up. Another idea I had was to see what is being posted to news groups.
I found a site called Newzbin where they index all sorts of USENET content. One of those is music video clips. All that is needed after that is a program to process the XML files they provide and also a connection to a newsserver and something to UNRAR and PAR2VERIFY the files.
I wrote a little Python script to coordinate the process. You can get the script here.
Below is a checklist of what you will need if I've confused you:
To use the script, simply save a message ID file from Newzbin to a folder. Switch to that folder in a terminal / command window and run the python script e.g. python pnzb.py.
Python module to provide blowfish encryption / decryption.
The module was copied from Michael Gilfix's algorithm. I then added two helper functions decryptPwd and encryptPwd to make encryption and decryption easier.
Usage is as follows:
import blowfish
# Encrypting a password
encryptedPwd = blowfish.encryptPwd ('your key', 'password')
# Decrypting a password
decryptedPwd = blowfish.decryptPwd ('your key', encryptedPwd)
Link to python module:
blowfish.py