<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 23-02-2010 15:21, Thomas wrote:
<blockquote
cite="mid:0b222aec-db04-45b7-9f86-e2839ffafc40@j1g2000vbl.googlegroups.com"
type="cite">
<pre wrap="">On Feb 22, 9:27 pm, MRAB <a class="moz-txt-link-rfc2396E" href="mailto:pyt...@mrabarnett.plus.com"><pyt...@mrabarnett.plus.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Stef Mientki wrote:
</pre>
<blockquote type="cite">
<pre wrap="">hello,
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">in my python desktop applications,
I'ld like to implement a crash reporter.
By redirecting the sys.excepthook,
I can detect a crash and collect the necessary data.
Now I want that my users sends this information to me,
and I can't find a good way of doing this.
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">The following solutions came into my mind:
(most of my users are on Windows, and the programs are written in Python
2.6)
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">1. mailto:
doesn't work if the the user didn't install a default email client,
or if the user uses a portable email client (that isn't started yet)
Besides this limits the messages to small amounts of data.
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">2.other mail options: smtp
AFAIK such a solution needs smtp authorization, and therefor I've to put
my username and password in the desktop application.
</pre>
</blockquote>
<pre wrap="">
Try reading the documentation for Python's smtplib module.
You don't need to provide any password.
</pre>
<blockquote type="cite">
<pre wrap="">3. http-post
Although post is also limited in size,
I could store information in cookies (don't know yet how), and cookies
are sent parallel to the post message.
On the server site I can use a small php script, that stores the
post-data, cookies and/or send's a (long) email.
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">are there better options ?- Hide quoted text -
</pre>
</blockquote>
<pre wrap="">
- Show quoted text -- Hide quoted text -
- Show quoted text -
</pre>
</blockquote>
<pre wrap="">
Try <a class="moz-txt-link-freetext" href="http://code.activestate.com/recipes/442459/">http://code.activestate.com/recipes/442459/</a>
</pre>
</blockquote>
<font size="+1"><br>
Apparently there's something terrible wrong on my system, because I do
need username and password :-(<br>
<br>
First, a script that works without username and password.<br>
I guess it works, because the smtp_server is the smtp server of my
provider, and I'm in that domain of my provider,<br>
so it won't work for a random user of my program.<br>
if Test ( 4 ) :<br>
import smtplib<br>
from email.mime.text import MIMEText<br>
from email.mime.multipart import MIMEMultipart<br>
<br>
body = 'test_body'<br>
subject = 'test_subject'<br>
mail_to = '<a class="moz-txt-link-abbreviated" href="mailto:s.mientki@ru.nl">s.mientki@ru.nl</a>'<br>
mail_from = '<a class="moz-txt-link-abbreviated" href="mailto:stef.mientki@gmail.com">stef.mientki@gmail.com</a>'<br>
<br>
msg = MIMEMultipart ( 'alternative' )<br>
msg [ 'To' ] = mail_to<br>
msg [ 'From' ] = mail_from<br>
msg [ 'Subject' ] = subject<br>
<br>
part1 = MIMEText ( body, 'plain' )<br>
msg.attach ( part1 )<br>
<br>
smtp_server = 'mail.upcmail.nl'<br>
session = smtplib.SMTP ( smtp_server )<br>
session.sendmail ( mail_from, [mail_to], msg.as_string() )<br>
<br>
<br>
Using smtp on google , works only if I support username and password:<br>
if Test ( 5 ) :<br>
import smtplib<br>
from email.mime.text import MIMEText<br>
from email.mime.multipart import MIMEMultipart<br>
<br>
body = 'test_body'<br>
subject = 'test_subject'<br>
mail_to = '<a class="moz-txt-link-abbreviated" href="mailto:s.mientki@ru.nl">s.mientki@ru.nl</a>'<br>
mail_from = '<a class="moz-txt-link-abbreviated" href="mailto:stef.mientki@gmail.com">stef.mientki@gmail.com</a>'<br>
<br>
msg = MIMEMultipart ( 'alternative' )<br>
msg [ 'To' ] = mail_to<br>
msg [ 'From' ] = mail_from<br>
msg [ 'Subject' ] = subject<br>
<br>
part1 = MIMEText ( body, 'plain' )<br>
msg.attach ( part1 )<br>
<br>
smtp_server = 'smtp.gmail.com'<br>
session = smtplib.SMTP ( smtp_server, 587 )<br>
session.ehlo ( mail_from )<br>
session.starttls ()<br>
session.ehlo ( mail_from )<br>
session.login (username, password )<br>
session.sendmail ( mail_from, [mail_to], msg.as_string() )<br>
<br>
<br>
And her a number of different tries with localhost / mail :<br>
if Test ( 6 ) :<br>
import smtplib<br>
from email.mime.text import MIMEText<br>
from email.mime.multipart import MIMEMultipart<br>
<br>
body = 'test_body'<br>
subject = 'test_subject'<br>
mail_to = '<a class="moz-txt-link-abbreviated" href="mailto:s.mientki@ru.nl">s.mientki@ru.nl</a>'<br>
mail_from = '<a class="moz-txt-link-abbreviated" href="mailto:stef.mientki@gmail.com">stef.mientki@gmail.com</a>'<br>
<br>
msg = MIMEMultipart ( 'alternative' )<br>
msg [ 'To' ] = mail_to<br>
msg [ 'From' ] = mail_from<br>
msg [ 'Subject' ] = subject<br>
<br>
part1 = MIMEText ( body, 'plain' )<br>
msg.attach ( part1 )<br>
<br>
session = smtplib.SMTP ( 'localhost' )<br>
"""<br>
Traceback (most recent call last):<br>
File "D:\Data_Python_25\support\mail_support.py", line 375, in
<module><br>
session = smtplib.SMTP ( smtp_server )<br>
File "P:\Python26\lib\smtplib.py", line 239, in __init__<br>
(code, msg) = self.connect(host, port)<br>
File "P:\Python26\lib\smtplib.py", line 295, in connect<br>
self.sock = self._get_socket(host, port, self.timeout)<br>
File "P:\Python26\lib\smtplib.py", line 273, in _get_socket<br>
return socket.create_connection((port, host), timeout)<br>
File "P:\Python26\lib\socket.py", line 514, in create_connection<br>
raise error, msg<br>
error: [Errno 10061] No connection could be made because the target
machine actively refused it<br>
"""<br>
#session = smtplib.SMTP ( 'localhost', 25 )<br>
#session = smtplib.SMTP ( 'mail', 25 )<br>
session = smtplib.SMTP ( 'mail', 1025 )<br>
"""<br>
Traceback (most recent call last):<br>
File "D:\Data_Python_25\support\mail_support.py", line 377, in
<module><br>
session = smtplib.SMTP ( 'mail', 1025 )<br>
File "P:\Python26\lib\smtplib.py", line 239, in __init__<br>
(code, msg) = self.connect(host, port)<br>
File "P:\Python26\lib\smtplib.py", line 295, in connect<br>
self.sock = self._get_socket(host, port, self.timeout)<br>
File "P:\Python26\lib\smtplib.py", line 273, in _get_socket<br>
return socket.create_connection((port, host), timeout)<br>
File "P:\Python26\lib\socket.py", line 500, in create_connection<br>
for res in getaddrinfo(host, port, 0, SOCK_STREAM):<br>
gaierror: [Errno 11001] getaddrinfo failed<br>
"""<br>
session.sendmail ( mail_from, [mail_to], msg.as_string() )<br>
<br>
<br>
What am I doing wrong ?<br>
<br>
cheers,<br>
Stef<br>
<br>
</font>
</body>
</html>