Receive e-mail

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2006
Posts: 3
Reputation: gYbU is an unknown quantity at this point 
Solved Threads: 0
gYbU gYbU is offline Offline
Newbie Poster

Receive e-mail

 
0
  #1
Mar 31st, 2006
I alredy know hoe to send e-mail by python but is possible to receive e-mail??
thanks for all post
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 3
Reputation: gYbU is an unknown quantity at this point 
Solved Threads: 0
gYbU gYbU is offline Offline
Newbie Poster

Re: Receive e-mail

 
0
  #2
Apr 4th, 2006
or how to delete all email
please
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,057
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 131
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Receive e-mail

 
0
  #3
Apr 4th, 2006
I'm really confused what you're asking. Can you explain further please?
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,151
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 952
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Receive e-mail

 
0
  #4
Apr 4th, 2006
I imagine you used the smtplib module and its functions to send e-mail. Well, you use the poplib module and its functions to view and delete e-mail.

Use help('poplib') to get details.

A rather crummy example is at
http://docs.python.org/lib/pop3-example.html
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 3
Reputation: gYbU is an unknown quantity at this point 
Solved Threads: 0
gYbU gYbU is offline Offline
Newbie Poster

Re: Receive e-mail

 
0
  #5
Apr 4th, 2006
Originally Posted by cscgal
I'm really confused what you're asking. Can you explain further please?
YOu know password and username.You want to delete all of the mails in the box using python...
I alredy know how to send e-mail,how to receive.Thanks for all help
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 138
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Re: Receive e-mail

 
0
  #6
Apr 7th, 2006
Found code in one of the books in the CS library:
  1. # view and delete e-mail using the POP3 protocol
  2.  
  3. import sys, getpass, poplib, re
  4.  
  5. # change according to your needs
  6. POPHOST = "pop.domain.com"
  7. POPUSER = "joedoe"
  8. POPPASS = ""
  9. # the number of message body lines to retrieve
  10. MAXLINES = 10
  11. HEADERS = "From To Subject".split()
  12.  
  13. # headers you're actually interested in
  14. rx_headers = re.compile('|'.join(headers), re.IGNORECASE)
  15.  
  16. try:
  17. # connect to POP3 and identify user
  18. pop = poplib.POP3(POPHOST)
  19. pop.user(POPUSER)
  20.  
  21. if not POPPASS or POPPASS=='=':
  22. # if no password was supplied, ask for it
  23. POPPASS = getpass.getpass("Password for %s@%s:" % (POPUSER, POPHOST))
  24.  
  25. # authenticate user
  26. pop.pass_(POPPASS)
  27.  
  28. # get general information (msg_count, box_size)
  29. stat = pop.stat( )
  30.  
  31. # print some information
  32. print "Logged in as %s@%s" % (POPUSER, POPHOST)
  33. print "Status: %d message(s), %d bytes" % stat
  34.  
  35. bye = 0
  36. count_del = 0
  37. for n in range(stat[0]):
  38.  
  39. msgnum = n+1
  40.  
  41. # retrieve headers
  42. response, lines, bytes = pop.top(msgnum, MAXLINES)
  43.  
  44. # print message info and headers you're interested in
  45. print "Message %d (%d bytes)" % (msgnum, bytes)
  46. print "-" * 30
  47. print "\n".join(filter(rx_headers.match, lines))
  48. print "-" * 30
  49.  
  50. # input loop
  51. while 1:
  52. k = raw_input("(d=delete, s=skip, v=view, q=quit) What?")
  53. k = k[:1].lower( )
  54. if k == 'd':
  55. # Mark message for deletion
  56. k = raw_input("Delete message %d? (y/n)" % msgnum)
  57. if k in "yY":
  58. pop.dele(msgnum)
  59. print "Message %d marked for deletion" % msgnum
  60. count_del += 1
  61. break
  62. elif k == 's':
  63. print "Message %d left on server" % msgnum
  64. break
  65. elif k == 'v':
  66. print "-" * 30
  67. print "\n".join(lines)
  68. print "-" * 30
  69. elif k == 'q':
  70. bye = 1
  71. break
  72.  
  73. # done ...
  74. if bye:
  75. print "Bye"
  76. break
  77.  
  78. # summary
  79. print "Deleting %d message(s) in mailbox %s@%s" % (
  80. count_del, POPUSER, POPHOST)
  81.  
  82. # close operations and disconnect from server
  83. print "Closing POP3 session"
  84. pop.quit( )
  85.  
  86. except poplib.error_proto, detail:
  87.  
  88. # possible error
  89. print "POP3 Protocol Error:", detail
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 18
Reputation: sharma_vivek82 is an unknown quantity at this point 
Solved Threads: 0
sharma_vivek82 sharma_vivek82 is offline Offline
Newbie Poster

Re: Receive e-mail

 
0
  #7
Apr 20th, 2006
hey, why i am getting this error..
can anyone explain me
Traceback (most recent call last):
File "popmail.py", line 14, in ?
rx_headers = re.compile('|'.join(headers), re.IGNORECASE)
NameError: name 'headers' is not defined
[B]
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,151
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 952
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Receive e-mail

 
0
  #8
Apr 20th, 2006
There is a booboo in the book, headers should be HEADERS.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum


Views: 4244 | Replies: 7
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC