Solved

Forwarding Mail from Mailbox

Posted on 1998-04-21
9
335 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:

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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now