Which split delimiter to use for mailbox

B

Bart Van der Donck

Hello,

I'm reading an email inbox file in Perl like /usr/boxes/mydomain.com/
info. This file consists of 1 or more mails that are waiting to be
delivered. Which mechanism is safe enough to split this file in order
to know the number of waiting emails ?

The format looks like this:

From (e-mail address removed) Wed Mar 12 19:14:17 2008
[headers]
[blanc line]
[body]
[blanc line]
From (e-mail address removed) Wed Mar 12 19:50:11 2008
[headers]
[blanc line]
[body]
[blanc line]
From (e-mail address removed) Wed Mar 12 21:47:07 2008
[headers]
[blanc line]
[body]

I don't understand how Perl can split this input reliably, so that it
knows where a next mail starts. I mean, every message could also
contain blanc lines or "From (e-mail address removed)" itself.

Thanks,
 
M

Martijn Lievaart

Hello,

I'm reading an email inbox file in Perl like /usr/boxes/mydomain.com/
info. This file consists of 1 or more mails that are waiting to be
delivered. Which mechanism is safe enough to split this file in order to
know the number of waiting emails ?

The format looks like this:

From (e-mail address removed) Wed Mar 12 19:14:17 2008 [headers]
[blanc line]
[body]
[blanc line]
From (e-mail address removed) Wed Mar 12 19:50:11 2008 [headers]
[blanc line]
[body]
[blanc line]
From (e-mail address removed) Wed Mar 12 21:47:07 2008 [headers]
[blanc line]
[body]

I don't understand how Perl can split this input reliably, so that it
knows where a next mail starts. I mean, every message could also contain
blanc lines or "From (e-mail address removed)" itself.

The delimiter is '\n\nFrom'. It it occurs in the body it should be
escaped (by putting a '>' before the 'From' IIRC).

HTH,
M4
 
C

ccc31807

Hello,

I'm reading an email inbox file in Perl like /usr/boxes/mydomain.com/
info. This file consists of 1 or more mails that are waiting to be
delivered. Which mechanism is safe enough to split this file in order
to know the number of waiting emails ?

The format looks like this:

From (e-mail address removed) Wed Mar 12 19:14:17 2008
[headers]
[blanc line]
[body]
[blanc line]
From (e-mail address removed) Wed Mar 12 19:50:11 2008
[headers]
[blanc line]
[body]
[blanc line]
From (e-mail address removed) Wed Mar 12 21:47:07 2008
[headers]
[blanc line]
[body]

I don't understand how Perl can split this input reliably, so that it
knows where a next mail starts. I mean, every message could also
contain blanc lines or "From (e-mail address removed)" itself.

Thanks,

Count the '^Froms'. That will give you an accurate count of the number
of separate messages and you don't need a delimiter.

CC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,799
Latest member
Mercury_Dev

Latest Threads

Top