forwarding unread mail in /var/mail/<userid>

forwarding unread mail in /var/mail/<userid>

am 05.03.2007 18:34:59 von randyvp

I've been converting users over from using linux mail accounts to
Outlook by using /etc/aliases to redirect new linux mail to the new
primary email destination. I've noticed however some old mail in /
var/mail/ has not been read and I was just trying to determine
if there are any utilities to process a users's mbox and forward it to
their new mail account.

Any help would be appreciated.

Thanks
Randy

Re: forwarding unread mail in /var/mail/<userid>

am 05.03.2007 21:26:51 von Garen Erdoisa

randyvp@gmail.com wrote:
> I've been converting users over from using linux mail accounts to
> Outlook by using /etc/aliases to redirect new linux mail to the new
> primary email destination. I've noticed however some old mail in /
> var/mail/ has not been read and I was just trying to determine
> if there are any utilities to process a users's mbox and forward it to
> their new mail account.
>
> Any help would be appreciated.

cd /var/mail
cat oldusername |formail -s sendmail -oi newusername@example.net

The above uses the feature in formail that will read a data pipe and
split the messages it finds into new messages, then feed those messages
one at a time to whatever program you specify on the command line, in
this case sendmail. It actaully creates a new process ID for each
instance of sendmail. The -oi command line switch on sendmail tells
sendmail to expect an EOF as the message terminator(s) instead of a
.
This will also change the Return-Path: on each message processed to that
of the account from which you forwarded the email.

If you want to get a bit fancier about it, you could use procmail to
process each message, and write a procmail recipe to keep the old
Return-Path: information in an X-header, and/or add more X-headers
explaining that the message was resent due to a system change. This
would provide some additional tracking information that will help avoid
any confusion in the future about how the messages were processed. Using
a procmail approach would also allow you to suppress forwarding of any
FOLDER INTERNAL DATA messages that may be in the mailbox. :)

A better way IMO would be to just leave pop and/or imap access turned on
for the Linux box, then send out a message to your users to tell them
they have 30 to 90 days to collect their email from the old system after
which time it will be deleted.

--
Garen