[Tutor] Sending mail

Timo timomlists at gmail.com
Fri Mar 26 14:37:32 CET 2010


2010/3/25 Timo <timomlists at gmail.com>

> Hello,
>
> I was wondering what the best way is to send an email through my program? I
> want the user to send an email with an attachment.
>
> I do have a webspace, should I use the smtplib module if my webhost
> supports it (I have to ask though), or should I put a script on my space and
> communicate with that?
>
> Cheers,
> Timo
>


I worked on the following code. It works, but not for attachments.

On the webserver I have: http://python.pastebin.com/9m8MXxuR

And inside my program I then do:
form = urllib.urlencode([("from", send_from), ("to", send_to), ("subject",
subject), ("body", body), ("attachment", attachment)])
webbrowser.open(url + "?" + form)


So, 2 questions:
 - Is this a good way of sending mails over my webhost through my program?
 - Attachments don't work because I'm sending the path to the file, and
ofcourse the cgi script can't find it. How should I solve this?

Cheers,
Timo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100326/813b7abd/attachment.html>


More information about the Tutor mailing list