Solved

Forwarding Mail from Mailbox

Posted on 1998-04-21
9
345 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
llcommand 6 91
Virtualizing TAPE on dual VIOS 3 87
Correct syntax to upload file in a script using sftp 2 82
Expand a partition in Centos 7 Linux with Virtualmin 1 62
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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.:
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…

770 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