Re: Writing the 'From ' line

Bill Moseley <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.mail-box
Message-ID <[email protected]>
On Wed, Jan 21, 2004 at 08:38:54AM +0100, Mark Overmeer wrote:

> > moseley@bumby:~/hyper$ cat t.pl
> > use Mail::Box::Manager;
> > my $box = Mail::Box::Manager->new->open('test3') || die $!;
> > my @messages = $box->messages;
> > print $messages[0],"\n";
> > print $messages[0]->fromLine;
> > print $messages[0]->clone->fromLine;  # this doesn't work
> 
> These are interesting discussions for the mailinglist...

Oh, I missed that we moved off the list.  Now back on.

> You should see message objects as immutable. Changing a body is a sin,
> and changing header lines often not acceptable.  Only in some cases,
> adding or deleting header files does not imply a change in the message
> (for instance playing with the Received fields)

Ok.  So, say you want to go through all messages and add a header and
write back to the same mbox.  Do you have to clone and write it as a new
message?

> A clone is rarely needed: it is only required when you take one message
> and then base a new message on that.  Where the original message is
> attached to folder, the new message is not!  When the original message
> is a Mail::Box::Mbox::Message, the clone is simply a Mail::Message.
> When you attach that message to an mbox folder, it will be coerced into
> a Mail::Box::Mbox::Message again, but it may also get coerced into
> a Mail::Box::IMAP4::Message or whatever.

That's ok.  But are you saying that it may loose the "fromLine" along
the way?  That makes sense in that the fromLine is a mbox thingy --
although it's nice to retain as much envelope info as possible.

Back to the ->clone.  I was first reading messages from one mail box,
sorting them, and then writing them back to a new mailbox.  When I
didn't clone I was getting:

  Attempt to free unreferenced scalar: SV 0x8575844.

> There are more people wanting me to change things around the fromLine.
> For instance, sometimes Mail::Message->read(\*STDIN) tumbles over it,
> when (for instance) sendmail is conifgured to pass it on.  So it may
> well be that in one of the coming releases, any kind of message has
> such a line.  I'm still hesitating.

Hope I'm following, but The 'From ' is a mbox thing.  But, if messages
were read from a mbox and written to maildir then it would be nice to
somehow retain that data -- like adding an Envelope-To: and
Delivery-date: header from the address and date in the 'From ' line.
Assuming those headers are not already there.

I'm making that up because I don't know what the RFCs say.  My comment
is that data should not be lost in the translation.

-- 
Bill Moseley
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.