Solved

Forwarding Mail from Mailbox

Posted on 1998-04-21
9
362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

705 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