Solved

Forwarding Mail from Mailbox

Posted on 1998-04-21
9
353 Views
Last Modified: 2010-04-21
Hi...

I have a system setup that forwards mail automatically to another system. When that other system is down it stores it in a mailbox.
My question is what command do I use to re-send the messages in that mailbox when the system comes up again.
Suppose the mailbox is in the file: /var/mail/root

The complication is that I want the messages sent as individual messages as they came in the box not as one big message going out.

Thanks for your help.
0
Comment
Question by:goodboy042198
  • 5
  • 4
9 Comments
 

Author Comment

by:goodboy042198
ID: 2006362
I tried the command:
mail email@address.com < /var/mail/root
and the message came out as one big one instead of little individual ones.

Hope you can help.
Thanks.
0
 
LVL 1

Expert Comment

by:OM
ID: 2006363
Waht box are you using ? What mailer are you using ?
If you use sendmail it is a already a feature.

0
 

Author Comment

by:goodboy042198
ID: 2006364
Yes I am using Sendmail. What command would I use?

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:OM
ID: 2006365
man sendmail :

     -q[time]        Process saved messages in the queue at given
                    intervals.   If  time is omitted, process the
                    queue  once.   time  is  given  as  a  tagged
                    number,   with   s  being  seconds,  m  being
                    minutes, h being hours, d being days,  and  w
                    being  weeks.   For example, -q1h30m or -q90m
                    would both set the timeout to one hour thirty
                    minutes.

0
 

Author Comment

by:goodboy042198
ID: 2006366
Hi..

Unfortunately this won't work because the mail is no longer in the queue but has been sent to a mailbox.
Is there a way around this?

0
 
LVL 1

Accepted Solution

by:
OM earned 50 total points
ID: 2006367
nawk 'BEGIN{cmd="/usr/lib/sendmail -t";} /^From /{close(cmd); next;} {print | cmd }' < /var/mail/root

Funny, isn't it ?
0
 

Author Comment

by:goodboy042198
ID: 2006368
Terrific. Thank you very very much. It works great.
Before you take the points and run off :o) could you just answer a quick question... i gather this is a script that reads in each line of the mailbox and separates each message by the "From " 
string..  is that correct? what if in the message itself there was a From string? I am sorry about all these questions i just want to be sure that it will always works.

Thanks. again

0
 
LVL 1

Expert Comment

by:OM
ID: 2006369
The script is spliting mailbox with File *begining* with
"From ". Mailer should replace lines begining with "From "
by " From " for example. If it is not done, you have to
consider the length of the body (if set) in the mail headers.
This will give you a little bit longer script but this
is possible to do it.
0
 

Author Comment

by:goodboy042198
ID: 2006370
Ok. This is what I thought. Thanks again!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question