mail filter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting mail filter
# 8  
Old 01-24-2002
Here is the version that I have.

lrwxr-xr-x 1 root sys 41 Sep 5 2000 sendmail -> /usr/localcw/opt/sendmail/sendmail.V8.9.3



I keep getting this error message.

Final-Recipient: RFC822; tm6858@sysname.com
X-Actual-Recipient: RFC822; |/root/urgent.sh@sysname.com
Action: failed
Status: 5.5.0
Last-Attempt-Date: Thu, 24 Jan 2002 09:30:08 -0600 (CST)

It's like it is trying to send the mail message to "/root/urgent.sh@sysname.com" as a user who would receive mail?


Does your script have the #!/bin/ksh at the top?
# 9  
Old 01-24-2002
Here is the script (only the names are changed) - same as what you posted:
/tmp/test2

#!/bin/ksh
#
if [ `grep urgent /tmp/test.tmp| wc -l` -gt 0 ]
then
mailx -s "urgent message" root < /tmp/test.tmp
else
mailx -s "mail forwarded from sysname" tghunter < /tmp/test.tmp
fi

I then have the alias hog in my alias file which runs /tmp/test2 when it gets email
hog: "|/tmp/test2"


I send a message to hog this way:
mailx -s"huh" hog < /tmp/test1.tmp

/tmp/test1.tmp contains:
this file has urgent in it


The original message never goes anywhere (because of the script). The script sends the file /tmp/test.tmp. The message I get in root mail is:

# mail
From daemon Thu Jan 24 10:45:47 2002
Date: Thu, 24 Jan 2002 10:45:47 -0500 (EST)
From: daemon
Message-Id: <200201241545.g0OFjlg05262@medusa.tampa.intermedia.com>
To: root
Subject: urgent message
Content-Length: 34

urgent - this is the file to send
thehoghunter
# 10  
Old 01-24-2002
The only other thing I can see from these postings is the alias you have.

Is it the correct format?

name: whitespace "|/tmp/script"
thehoghunter
# 11  
Old 01-24-2002
Everything looks good to me too.

This error message is strange.

----- Transcript of session follows -----
sh: urgent.sh not available for sendmail programs
554 |/root/urgent.sh... Service unavailable


I will try to see if there are any bugs in my version of Sendmail trying to use filters.

I will let you know...

Smilie Smilie
# 12  
Old 01-24-2002
This may be it - found on the sendmail.org FAQ -
Q3.34 -- What does "foo not available for sendmail programs" mean?
Date: September 24, 1999
It means that you are using smrsh, the sendmail restricted shell; see Q2.13 for details on this. To fix this problem, you need to create a sym-link from smrsh's directory for restricted programs to the program foo. The default location of this directory for restricted programs is /usr/adm/sm.bin in the Open Source version, but vendor versions differ. For example, RedHat Linux 6.0 uses /etc/smrsh, and Solaris 8 uses /var/adm/sm.bin . If you don't know the directory for your OS, first check the smrsh man page, then if that fails, try:

% strings /path/to/smrsh | grep ^/

where /path/to/smrsh is the P= argument on the Mprog line in sendmail.cf .
So for example:

% cd /usr/adm/sm.bin
% ln -s /usr/bin/vacation

would allow the vacation program to be run from a user's .forward file or an alias which uses the "|program" syntax.
Finally, if you want to disable use of smrsh, remove the FEATURE(`smrsh') line from the .mc file used to build sendmail.cf; see cf/README for details on this.
thehoghunter
# 13  
Old 01-24-2002
I still can't get it to work even though I did create the link as suggested.

I have contacted some technical folks in my group.

Will keep you posted.

Smilie
# 14  
Old 01-25-2002
solution

I found my solution.

2 problems.

1) my path was wrong. It should be only the filename in the /etc/aliases file like:

user: "|filename".


2) Also, I had the symlink in the wrong directory. Which I found out was not the /usr/adm/sm.bin that is prescribed for smrsh. Do a man on smrsh for details. Mine is /usr/localcw/bin.

# cd /usr/adm/sm.bin ##or /usr/localcw/bin in my case.
# ln -s /your/script/here . ## yes that is a period to put the link here in the current directory.

After that make sure the file that you are parsing is at least 555 for sendmail to process it. I had mine set to 700 which gave me errors.

Thanks for all the input. I hope this helps someelse in the future!

Smilie Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Client was not authenticated to send anonymous mail during MAIL FROM (in reply to MAIL FROM comm

I am having trouble getting mail to work on a red hat server. At first I was getting this message. Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
Discussion started by: cokedude
1 Replies

2. UNIX for Dummies Questions & Answers

Filter records in a huge text file from a filter text file

Hi Folks, I have a text file with lots of rows with duplicates in the first column, i want to filter out records based on filter columns in a different filter text file. bash scripting is what i need. Data.txt Name OrderID Quantity Sam 123 300 Jay 342 498 Kev 78 2500 Sam 420 50 Vic 10... (3 Replies)
Discussion started by: tech_frk
3 Replies

3. Linux

awk filter & Auto gen Mail

hi experts 2012-01-30 10:30:01:812 "y" "NA" "30/01/2012 10:30:01:154 AM" 2012-01-30 10:33:46:342 "y" "NA" "30/01/2012 10:33:45:752 AM" 2012-01-30 10:41:11:148 "n" "200" "30/01/2012 10:41:10:558 AM" 2012-01-30 10:44:48:049 "y" "NA" ... (7 Replies)
Discussion started by: nith_anandan
7 Replies

4. OS X (Apple)

Why are the subjects of deleted mail messages still in Mail Viewing pane?

I was wondering -- when I delete a mail message, I know it goes into the trash, but I've noticed that the subject lines of messages are still in the viewing pane, and I have to delete them as well. Can anyone tell me why this is, and where they are? (1 Reply)
Discussion started by: Straitsfan
1 Replies

5. UNIX for Advanced & Expert Users

need to configure mail setting to send mail to outlook mail server

i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail. actually i am trying to automate the high... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

6. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

7. Solaris

how to forward mail in /var/mail/username to external mail

Dear All, Now I use solaris 10 and I try to forward mail from /var/mail/username to their external mail so what should I do? thank u in advance (2 Replies)
Discussion started by: unitipon
2 Replies

8. UNIX for Advanced & Expert Users

Mail Filter

hai friends. How can i filter the incoming mails to an individual folder.. I am using sendmail. Thanks in advance Collins (4 Replies)
Discussion started by: collins
4 Replies

9. UNIX for Dummies Questions & Answers

mail problem (NOT Mail or Mail.app)

When I try to use the CLI mail, I get the following error. What's wrong? Welcome to Darwin! % mail root Subject: test test . EOT % /etc/mail/sendmail.cf: line 81: fileclass: cannot open /etc/mail/local-host-names: Group writable directory Do I just need to change the... (1 Reply)
Discussion started by: chenly
1 Replies
Login or Register to Ask a Question