Hello.

Before i embark on the grand search for the next few days of my life (hey who needed them anyways) i wondered if this was possible cause in my head i can't imagine a program being able to do this due to a difference in email clients etc

basically .... i have a button you can press that says "contact me", since i won't be running this on my computer but giving it to friends i won't know what their machines are running (outlook, thunderbird, outlook express etc etc) so if a contact me button is pressed, it will start a "new mail" from the client machines default email client and auto insert my email address and know which internet service the client machine uses so it can send the email out.

I'm guessing this is possible but it would be a major undertaking as all the different email programs would store info like SMPT server differently... or even if i built it into the program when you type "contact me" and you write the text in the program itself and click send if there was a way to get this info .... knowing that it could be run from different versions of windows (at least just windows for now)

Is this a really complicated over the top thing or quite possible .. if it is possible, please give me a direction to look, i'll research this but one more day of uni before a 3 day break ... knowing where to look could save me a bundle of time that i'm restricted in.

Thanks for your time.

In windows command line: start mailto:<email_addy>@<domain> will open the default mail client and create a new message to <email_addy>@<domain>. So simply pop that into os.system or subprocess or whatever your method of choice is, and that will take care of a windows platform machine.

I know there's something similar on linux machines but I'm drawing a blank at the moment...

The problem with this method comes into play when considering that most people prefer web-based email clients (at least according to a recent lifehacker poll). I know there are hacks to make an OS default to a web-based client instead of an installed piece of software, but I'm sure most of your users wouldn't be that savvy.

How's this for a solution:

Instead of worrying about what email client your users are using, have python send the email for them, through an account that you set up!

It's fairly easy to get python to send email if you have an email account with smtp. Your GUI would let them enter their message and send it.

I had an issue where I wanted a script to send me an email when it finished running. So I set up the script with it's very own gmail account. Completely automated and works great.

Also would be completely invisible, no need to open a browser window etc.

I like both solutions and the first reply was definately what i had in mind but i did not even consider the fact about web based emails, so thats a fair point.

So the second answer which i also mentioned sounds good, and yeah i didn't know you could dothat, i see a search for gmail brings up a few hits so i'll do some reading tonight when i get home.
Thanks for the replies, if you know of anything else i should know or some code tip, would love to hear it as i'm pretty much reading and copying code on this part as it is well beyond my abilities i think, mostly cause i just learnt RIGHT NOW that this was even possible and can't quite visualise it.

I already have a nice barely used gmail account at least :)

Here's a function to send email from a gmail account:

def email(usertuple,sender,to,subject,msg):
    """Sends an email from a gmail account"""
    (login,pswd) = usertuple
    print 'Connecting...'
    mailServer = smtplib.SMTP("smtp.gmail.com", 0)
    print 'Initiating relationship...'
    mailServer.ehlo()
    print 'Encrypting...'
    mailServer.starttls()
    print 'Initiating encrypted relationship...'
    mailServer.ehlo()
    print 'Logging in...'
    mailServer.login(login,pswd)
    print 'Mailing stuff...'
    message = """\
From: %s
To: %s
Subject: %s

%s
""" % (sender, to, subject, msg)
    mailServer.sendmail(login,to,message)
    print 'Quitting...'
    mailServer.close()

i haven't yet had a great deal of time to tackle this cept for a piece of cut and paste here and there to see what happens and how it works with no success, i was also aware of reading everywhere you need to sdweitch om SMTP at Gmail through their settings and i swear there is no such setting there.
research research research

Honestly you should never cut and paste. Ask questions about bits you don't understand. Rename variables at the very least so that you know where everything is going.

When you say it's not working, try to interpret the error you get. Or post it here and let us see it.

That is what i do .. i just didn't write that all out, i just wrote the above statement as "cut and paste"

I tried to get this project completed before i went back to uni cause uni takes all my time and eats it (doesn't help i live 1 1/2 hours drive away so even a 2 hour class becomes a 5 hour day mim :(

Anyways .. yeah, i cut and paste followed by editting variables to match my code, see if i can imcorperate it into my own GUI etc. I might get a look at this in the next 2 days i hope as serisouly .. i'm loving this but i can't let it get in my way of Uni stuff ..

Thanks for the continual help.

This article has been dead for over six months. Start a new discussion instead.