Having some troubles downloading messages with POP3...
I can connect to the server just fine and list messages without any
problem with the following code:
------------------------
from poplib import *
server = POP3("mail.blue bottle.com")
print server.getwelco me()
print server.user("ne *******@bluebot tle.com")
print server.pass_("x xxxxxxx")
messagesInfo = server.list()[1]
numMessages = len(messagesInf o)
print numMessages
------------------------
However, if I try to actually download the messages themselves, my
python editor highlights 'msgSize' and says "invalid syntax" when I run
the following subsequent lines of code:
------------------------
emails = []
for msg in messagesInfo:
msgNum = int(split(msg, " ")[0]
msgSize = int(split(msg, " ")[1]
if(msgSize < 20000):
messages = server.retr(msg Num)[1]
messages = join(message, "\n")
emails.append(m essage)
------------------------
anyone know what's wrong? thanks. 8 1640
Dennis Lee Bieber wrote: On Sat, 18 Mar 2006 16:44:44 -0500, Kevin F <ne*******@gmai l.com> declaimed the following in comp.lang.pytho n:
However, if I try to actually download the messages themselves, my python editor highlights 'msgSize' and says "invalid syntax" when I run the following subsequent lines of code:
------------------------ emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] msgSize = int(split(msg, " ")[1] if(msgSize < 20000): messages = server.retr(msg Num)[1] messages = join(message, "\n") emails.append(m essage)
Look very closely at your indentation
I fixed the indentation to:
emails = []
for msg in messagesInfo:
msgNum = int(split(msg, " ")[0]
msgSize = int(split(msg, " ")[1]
if(msgSize < 20000):
messages = server.retr(msg Num)[1]
messages = join(message, "\n")
emails.append(m essage)
and it still doesn't work, what's wrong?
Dennis Lee Bieber wrote: On Sat, 18 Mar 2006 17:24:05 -0500, Kevin F <ne*******@gmai l.com> declaimed the following in comp.lang.pytho n:
I fixed the indentation to:
emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] msgSize = int(split(msg, " ")[1]
Now look at your parentheses... and it still doesn't work, what's wrong?
msgNum = int(split(msg, " ")[0] HINT: 0 1 2 1 ?
i have no idea what you are hinting at, can you please just tell me what
i need to change?
"Kevin F" <ne*******@gmai l.com> wrote in message
news:dv******** ***@netnews.upe nn.edu... Dennis Lee Bieber wrote: On Sat, 18 Mar 2006 16:44:44 -0500, Kevin F <ne*******@gmai l.com> declaimed the following in comp.lang.pytho n:
However, if I try to actually download the messages themselves, my python editor highlights 'msgSize' and says "invalid syntax" when I run the following subsequent lines of code:
------------------------ emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] msgSize = int(split(msg, " ")[1] if(msgSize < 20000): messages = server.retr(msg Num)[1] messages = join(message, "\n") emails.append(m essage)
Look very closely at your indentation
I fixed the indentation to:
emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] msgSize = int(split(msg, " ")[1] if(msgSize < 20000): messages = server.retr(msg Num)[1] messages = join(message, "\n") emails.append(m essage)
and it still doesn't work, what's wrong?
See comments.
-- Paul
emails = []
for msg in messagesInfo:
msgNum = int(split(msg, " ")[0] # line is missing closing paren
msgSize = int(split(msg, " ")[1] # line is missing closing paren,
too
if(msgSize < 20000): # this line should not be
further indented
messages = server.retr(msg Num)[1]
messages = join(message, "\n")
emails.append(m essage)
Paul McGuire wrote: "Kevin F" <ne*******@gmai l.com> wrote in message news:dv******** ***@netnews.upe nn.edu... Dennis Lee Bieber wrote: On Sat, 18 Mar 2006 16:44:44 -0500, Kevin F <ne*******@gmai l.com> declaimed the following in comp.lang.pytho n:
However, if I try to actually download the messages themselves, my python editor highlights 'msgSize' and says "invalid syntax" when I run the following subsequent lines of code:
------------------------ emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] msgSize = int(split(msg, " ")[1] if(msgSize < 20000): messages = server.retr(msg Num)[1] messages = join(message, "\n") emails.append(m essage) Look very closely at your indentation
I fixed the indentation to:
emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] msgSize = int(split(msg, " ")[1] if(msgSize < 20000): messages = server.retr(msg Num)[1] messages = join(message, "\n") emails.append(m essage)
and it still doesn't work, what's wrong?
See comments. -- Paul
emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] # line is missing closing paren msgSize = int(split(msg, " ")[1] # line is missing closing paren, too if(msgSize < 20000): # this line should not be further indented messages = server.retr(msg Num)[1] messages = join(message, "\n") emails.append(m essage)
thanks, that helped fix the syntax error, however, now when i run it, it
gives me an error for 'split', saying "name 'split' is not defined"
i'm new to python so bear with me but how do i fix this?
On Sat, 18 Mar 2006 18:34:56 -0500, Kevin F wrote: Dennis Lee Bieber wrote: On Sat, 18 Mar 2006 17:24:05 -0500, Kevin F <ne*******@gmai l.com> declaimed the following in comp.lang.pytho n:
I fixed the indentation to:
emails = [] for msg in messagesInfo: msgNum = int(split(msg, " ")[0] msgSize = int(split(msg, " ")[1]
Now look at your parentheses... and it still doesn't work, what's wrong?
msgNum = int(split(msg, " ")[0] HINT: 0 1 2 1 ? i have no idea what you are hinting at, can you please just tell me what i need to change?
I know how you feel; it's brutal trying to get elementary information from
this group.
I think what he is hinting at is that you are missing a right parentheses.
msgNum = int(split(msg, " ")[0]
should be:
msgNum = int(split(msg, " "))[0]
msgSize = int(split(msg, " ")[1]
should be:
msgSize = int(split(msg, " "))[1]
Now if only somebody would tell me, with elementary examples, how you
write to the thing called 'stdout' and how you read from 'stdin'.
Kevin F <ne*******@gmai l.com> wrote:
... msgSize = int(split(msg, " ")[1] # line is missing closing paren,
... thanks, that helped fix the syntax error, however, now when i run it, it gives me an error for 'split', saying "name 'split' is not defined"
i'm new to python so bear with me but how do i fix this?
you change the above-quoted assignment into:
msgSize = int(msg.split()[1])
and similarly for other occurrences of split, which is a string method
(and needs to be called as such) and not a builtin function.
Alex
Bob Piton wrote: On Sat, 18 Mar 2006 18:34:56 -0500, Kevin F wrote:i have no idea what you are hinting at, can you please just tell me what i need to change?
I know how you feel; it's brutal trying to get elementary information from this group.
You could try the python-tutor list, it tends to give more focused
answers to newbie questions than this group, which is pretty
newbie-friendly but does have a tendency to veer widely from the
original question.
Now if only somebody would tell me, with elementary examples, how you write to the thing called 'stdout' and how you read from 'stdin'.
raw_input() prompts to stdout and reads from stdin. print outputs to stdout:
In [53]: print raw_input('What is your name? ')
What is your name? Kent
Kent
or import sys and use sys.stdin and sys.stdout.
Kent
Bob Piton wrote: I think what he is hinting at is that you are missing a right parentheses.
msgNum = int(split(msg, " ")[0] should be: msgNum = int(split(msg, " "))[0]
Or more likely:
msgNum = int(split(msg, " ")[0])
msgSize = int(split(msg, " ")[1] should be: msgSize = int(split(msg, " "))[1]
Similarly:
msgSize = int(split(msg, " ")[0])
More readably:
msgNum, msgSize = [int(text) for text in split(msg, " ")[:2]]
Now if only somebody would tell me, with elementary examples, how you write to the thing called 'stdout' and how you read from 'stdin'.
import sys
print 'parrot' # writes to sys.stdout
print >>None, 'limburger' # Also writes to sys.stdout
print >>sys.stdout, 'roquefort' # Also writes to sys.stdout
sys.stdout.writ e('Shropshire -- the cheese of the gods\n) # Also
oneline = raw_input('prom pt: ') # reads from sys.stdin
for line in sys.stdin: # reads line from sys.stdin
print 'The current line is: %r' % line
if not line.strip():
break
chunk = sys.stdin.read( 23) # reads a series of bytes from sys.stdin
Warning: idle does not implement line iteration as in the for loop.
Also the read in both line iteration and .read(N) may well read the
input in "block mode", so you may have to type-ahead or end with an
end-of-file (^D for Unix, ^Z for Windows) before it starts processing
the lines.
--Scott David Daniels sc***********@a cm.org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: WebRod |
last post by:
Hi everybody,
I just would like to download the new mails I received on my POP3 server
(and keep a copy on the server)
I use PHP 4.3 and IMAP functions (they are compatible with both POP3 and
IMAP servers).
When I use OUTLOOK, no problem, in less than 5 seconds, it answers me:
" you have XX new messages"
|
by: Robin Becker |
last post by:
Hi, I'm getting vast numbers of fake upgrade emails containing some kind
of virus. My rather old client can be made to reject these based on some
patterns in the subject line. They're nearly all based on the word
'New', 'Latest', 'Microsoft', 'Patch', 'Pack', ... etc etc.
Is there a python tool that can be made to delete these from my POP3
mail box rather than let my client reject? Quite a few seem to have
semi-valid return addresses so...
|
by: Ajeet YS |
last post by:
Hello,
Well, I don't know if this is the right forum to post this query, but I
didn't find any other suitable one.
I am developing a program to access mails from a pop3 server's mailbox.
For this I am using System.Net.Sockets namespace. I am able to get all the
messages from the server & read them. Upon reading each mail DELE command is
executed, so that in the next session the same mail is not processed again.
|
by: Mike Brearley |
last post by:
I need to write a script that will check a catch-all mailbox (pop3) and send
a non delivery report back to the sender of the email.
Background info:
I have a domain hosted on a site that offers unlimited email accounts... the
problem is, emails sent to an invalid address on the domain aren't
automatically returned as non-deliverable. I am, however, able to set up a
catch-all address and able to pick up those emails. Id like to set up a...
|
by: Ken Yu |
last post by:
Hi,
I want to make a program for receive E-mail by POP3,
and forward to another E-mail Account, if the E-mail with Attachment
, will delete the attachment before forward, where can i find more
information
how to download E-mail by POP3 and control mail attachment and send out ?
Tks a Lot !
| |
by: Shimon Sim |
last post by:
Is there a way to get e-mails with attachments using .NET 2.0?
If not does anybody knows a component that can do this?
Thank you,
Shimon.
|
by: Pavils Jurjans |
last post by:
Hello list,
In order to do some mail processing before it ever gets to the mail client,
we plan to implement a POP3 proxy solution. Ie, POP3 mail client would
connect to the proxy instead of the actual POP3 mail server, and the proxy
would do the actual connection to the mail server, process the incoming
messages a little bit, and stream them to the mail client.
Could someone please point me to a decent solution, be it open source or...
|
by: rodny.romero |
last post by:
Somebody can help me with an example of like Reading post office with
VB.Net using protocol POP3, I have obtained the commandos or
instructions that protocol POP3 supports, but I have not been able to
arm a small form with some example that connectivity that consegui on
the other hand.
I am thankful if somebody has a complete example of connectivity to
the server and execution of commandos of protocol POP3 (Login, USER,
PASS,
APOP...
|
by: =?Utf-8?B?Q2hhcmxlcw==?= |
last post by:
Like many people, I normally use Yahoo! Mail via the web and like to keep all
my emails stored on the Yahoo! server. However sometimes I can’t get access
to a PC/the web and I download my emails to a PDA/palmtop via POP3. The PDA
uses Windows Mobile software. Since using the PDA, I have had the problem of
emails disappearing from the Yahoo! server. However I think I now understand
how to avoid this.
It seems that Windows Mobile is...
|
by: dansam |
last post by:
Hi everyone,
My question is how to download emails from a pop server and save them as *.eml or *.mht files to localdisk as oultlook does ?
Now what I know is that an .eml file can have images,attachments and all the e-mail formatting in it. So if I use a simple pop3 client to download message it will download the text part of the e-mail not full formatting - that's what I'm searching for!
I found this link :...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |