Making a Python program handle mailto links
Question: I actually found the answer to this before I asked the question, but I'm
posting it (and the answer, in an answer) for the sake of others who might
want to know (though if you have more insights, feel free to mention them).
EDIT: Someone else gave a better answer (so take note):

Question:

I made a Python program that is capable of sending email. However, I want to
make it capable of being a default email client such that it will capture the
email address and subject of HTML email links (mailto links) when the user
clicks them.

How do I get the email address and subject to my client?

Currently, I can set my program as the default mail client, but I don't know
what information, or format of information, it's getting from the web browser;
so, I'm not sure how to parse it.


Answer: Assuming the complete link is passed in as `sys.argv[1]`, you need to do
something like this:

    
    
    import urllib.parse
    parsed = urllib.parse.urlparse(sys.argv[1])
    mail_addr = parsed.path
    fields = urllib.parse.parse_qs(parsed.query)
    

This sets `mail_addr` to the address to send the email to, while `field` will
be a dictionary of additional parameters.

The fields that you can expect to be present are specified in [RFC
6068](http://tools.ietf.org/html/rfc6068)

