KSH - mailx - Redirect the undelivered mail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting KSH - mailx - Redirect the undelivered mail
# 1  
Old 01-06-2011
KSH - mailx - Redirect the undelivered mail

Hi,

I need to create one KSH which will send mail to set of recipients using "mailx" command like below.
Code:
mailx -s "Test mail" "test@yahoo.com, test@gmail.com" <$output.txt

The recipients are in different domains (like yahoo, gmail, etc.).

My requirement is, if any mail is undelivered, then I need to re-direct that notification to admin user (email id).

Please let me know if it is possible to re-direct the undelivered mail notification to another mail id.

Thanks.


---------- Post updated 01-06-11 at 04:41 PM ---------- Previous update was 01-05-11 at 11:25 PM ----------

Found one workaround for this.

Code:
mailx -r "admin@domain.com" -s "Email subject" "test@yahoo.com" <Emailbody.txt



This will send the undelivered notification to admin@domain.com email address.

But the note here is, if the recipient email address is valid, then they will receive the email with sender as admin@domain.com.

Please suggest if there are any other workaround available.

Thanks.
# 2  
Old 01-06-2011
Sending is no trick, it is automatically receiving and processing. You have to receive all to process any. Devote a new id as sender, and write a cron script on that id to get the mail one message at a time, sort them, save them, and remail any returns to admin. You might also email a summary of other mail to admin once a day, unless all other email if any is a week old. Or, you could mail all non-admin messages to another id.

Otherwise, you are talking about a lot of sendmail.conf programming to make the mail daemon do it, possibly destabilizing it.

You can get each incoming email processed immediately in some configurations using '|command_you_create' in ~/.forward, but this is not well thought of in security circles.
This User Gave Thanks to DGPickett For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Problems sending mail: Difference between Mail and Mailx?

Whats the difference between mail and mailx? I'm trying to troubleshoot a problem where I can send mail from server A with this `echo $MESSAGE | mail -s "$SUBJECT" -r $FROM $RECIPIENTS` command but executing the same command from server B throws me this error (Both servers are RHEL) ... (1 Reply)
Discussion started by: RedSpyder
1 Replies

2. Shell Programming and Scripting

Not able to send the mail using mail and mailx command

Hi All, I am trying to send a mail from linux server but could'nt able to send the mail. I tried the below syntax's so far but no luck. mail -s “Hello world” abc@xyz.com < /usr/g/txt.log cat "txt.log" | mailx -s "Hello world" abc@xyz.com mailx -s “Hello world” abc@xyz.com <... (2 Replies)
Discussion started by: scriptscript
2 Replies

3. Shell Programming and Scripting

Redirect within ksh

I am using ksh on an AIX box. I would like to redirect the stdout and stderr to a file but also show them on the terminal. Is this possible? I have tried tee within my file without success. This is the code I have so far exec > imp.log 2>&1 | tee exec 1>&1 I am new to shell scripting, so... (3 Replies)
Discussion started by: podzach
3 Replies

4. Shell Programming and Scripting

KSH problem - how do i redirect three times?

i need to output an ls command to a file but also capture any errors from that command and output them to a log file and the screen. if it's only possible to output them to a log file and not the screen then that's fine. this is what i've tried so far, but it won't populate log.txt. i've... (16 Replies)
Discussion started by: mjays
16 Replies

5. Shell Programming and Scripting

sending mail through mailx

while trying to send a mail, though the output file doesn't contain any exclamatory mark(!), i am getting that in the mail with an extra line. please help me out from this ASAP. (3 Replies)
Discussion started by: pvamsikr
3 Replies

6. UNIX for Advanced & Expert Users

mailx commannd - Mail and Attachment in same mail

Hi , I am using mailx command for sending the mails. Rightnow I am sending the attachment (by using uuencode $filename) as a seperate mail.I wanna send the attachment also with the same mail. (6 Replies)
Discussion started by: sharif
6 Replies

7. UNIX for Advanced & Expert Users

mailx on ksh revisited

I have read through all documents in FAQ and have run into an issue with sending an email with body message text and an email attachment. I have included what I have thus far and I can get the message body to send in the email to work only. I cannot understand the uuencode even after I read the... (5 Replies)
Discussion started by: tekline
5 Replies

8. Shell Programming and Scripting

ksh : using mailx and attachments

Hi I want to use mailx command to send a message included more than one file. I tried to use uuencode in pipe but it could only generate one file. I would avoid using an archive file :p Thanks to read you. Mathieu (2 Replies)
Discussion started by: madmat
2 Replies

9. Shell Programming and Scripting

redirect undelivered email address msg

i am creating a script that will send an email to a list of recepients listed in a file. if for some reason the mail was undelivered, is it possible to redirect the "undelivered email notification" to another email address? thanks! (0 Replies)
Discussion started by: tads98
0 Replies

10. UNIX for Dummies Questions & Answers

mail or mailx attachment

I have used the forum to determine the format required to send attachments from hp-ux 11. the problem I have is that using mailx does not attach the file, but subsititing mailx for mail on the command line attaches the file but i'm not able to specify a subject? The attachment has been convert... (3 Replies)
Discussion started by: brettmartin99
3 Replies
Login or Register to Ask a Question