[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: How do I do this in Python 3 (string.join())?
From:       Cameron Simpson <cs () cskk ! id ! au>
Date:       2020-08-27 22:26:45
Message-ID: 20200827222645.GA57785 () cskk ! homeip ! net
[Download RAW message or body]

On 27Aug2020 14:36, Chris Green <cl@isbd.net> wrote:
>Cameron Simpson <cs@cskk.id.au> wrote:
>> I do ok, though most of my message processing happens to messages
>> already landed in my "spool" Maildir by getmail. My setup uses getmail
>> to get messages with POP into a single Maildir, and then I process the
>> message files from there.
>>
>Most of my mail is delivered by SMTP, I run a Postfix SMTP *serever*
>on my desktop machine which stays on permanently.

I run postfix on my machines too, including my laptop, but mostly for 
sending - it means I can queue messages while offline, and they'll go 
out later.

I don't receive SMTP on my laptop (which is where my mail lives); I 
receive elsewhere such as the machine hosting my email domain (which 
also runs postfix), and the various external addresses I have (one for 
each ISP of course, and a couple of external email addresses such as a 
GMail one (largely to interact with stuff like Google Groups, which is 
pretty parochial).

So I use getmail to fetch from most of these (GMail just forwards a copy 
of everything "personal" to my primary address) and deliver to a spool 
Maildir on my laptop, and the mailfiler processes the spool Maildir.

>The POP3 processing is solely to collect E-Mail that ends up in the
>'catchall' mailbox on my hosting provider.  It empties the POP3
>catchall mailbox, checks for anything that *might* be for me or other
>family members then just deletes the rest.

Very strong email policy, that one. Personally I fear data loss, and 
process everything; anything which doesn't match a rule lands in my 
"UNKNOWN" mail folder for manual consideration when I'm bored. It is 
largely spam, but sometimes has a message wanting a new filing rule.

>> >E.g. in this case the only (well the only ready made) way to get a
>> >POP3 message is using poplib and this just gives you a list of lines
>> >made up of "bytes as text" :-
>> >
>> >    popmsg = pop3.retr(i+1)
>>
>> Ok, so you have bytes? You need to know.
>>
>The documentation says (and it's exactly the same for Python 2 and
>Python 3):-
>
>    POP3.retr(which)
>        Retrieve whole message number which, and set its seen flag. Result
>        is in form (response, ['line', ...], octets).
>
>Which isn't amazingly explicit unless 'line' implies a string.

Aye. But "print(repr(a_pop_line))" will tell you. Almost certainly a 
string-of-bytes, so I would expect bytes. The docs are probably 
unchanged during the Python2->3 move.

>> >I join the lines to feed them into mailbox.mbox() to create a mbox I
>> >can analyse and also a message which can be sent using SMTP.

Ah. I like Maildirs for analysis; every message has its own file, which 
makes adding and removing messages easy, and avoids contention with 
other things using the Maildir.

My mailfiler can process Maildirs (scan, add, remove) and add to 
Maildirs and mboxes.

Cheers,
Cameron Simpson <cs@cskk.id.au>
-- 
https://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic