Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 14th, 2005, 11:43 PM   #1
polernon
Newbie
 
Join Date: Oct 2005
Location: USA
Posts: 3
Rep Power: 0 polernon is on a distinguished road
How can I send e-mail via python?

Hello I am trying to write a python program that will send my log files to my email. Does python have a library that supports sending email? thanks

Last edited by polernon; Nov 15th, 2005 at 12:01 AM.
polernon is offline   Reply With Quote
Old Nov 15th, 2005, 12:12 AM   #2
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 312
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
http://docs.python.org/lib/module-smtplib.html

It's like, woah. Very first link on google too.
andro is offline   Reply With Quote
Old Nov 15th, 2005, 1:23 AM   #3
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 4 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
I've done this before, it was pretty cool.
I used smtplib to send mail and poplib to recieve it.
If you want to practice with it, use the Python shell.
__________________
Join us at #programmingforums @ irc.freenode.net!

My software never has bugs. It just develops random features.
coldDeath is offline   Reply With Quote
Old Nov 15th, 2005, 12:06 PM   #4
polernon
Newbie
 
Join Date: Oct 2005
Location: USA
Posts: 3
Rep Power: 0 polernon is on a distinguished road
Thanks for the help, I think the reason I didn't find it on google was because I wasn't sure what I was looking for. I got caught up on the gmail and msn libraries and expected something similar for general email.
polernon is offline   Reply With Quote
Old Dec 8th, 2005, 1:33 PM   #5
Klipt
Hobbyist Programmer
 
Join Date: Dec 2005
Posts: 118
Rep Power: 0 Klipt is an unknown quantity at this point
Their example doesn't work on the machine I'm on at the moment - it's WinXP, could it be due to security settings?

Quote:
>>> server = smtplib.SMTP('localhost')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python24\lib\smtplib.py", line 241, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python24\lib\smtplib.py", line 303, in connect
raise socket.error, msg
socket.error: (10061, 'Connection refused')
Klipt is offline   Reply With Quote
Old Dec 8th, 2005, 6:06 PM   #6
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,888
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
For the code: "smtplib.SMTP('localhost')", you need 'localhost' to be a mail server that you have working.

Mine for example, was a free account I setup at www.nerdshack.com, it worked very nicely. And I could recieve all the emails simply from Thunderbird/Outlook Explorer.

In that case, 'localhost' is replaced by: 'mail.nerdshack.com:2525'
Sane is offline   Reply With Quote
Old Dec 9th, 2005, 8:15 AM   #7
Klipt
Hobbyist Programmer
 
Join Date: Dec 2005
Posts: 118
Rep Power: 0 Klipt is an unknown quantity at this point
Ah, so you have to have a server address and port number now it works, thanks.
Klipt is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:04 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC