cancel
Showing results for 
Search instead for 
Did you mean: 

syntax for .forward file

SOLVED
Go to solution
Anthony Baldwin
Occasional Advisor

syntax for .forward file

Does anyone understand the syntax of the .forward file.

I was using it to plop email sent to a user into a specified directory. For example

\$user, "|cat > ~/mail_dir/mail_msg_$(date +%y-%m-%d-%H:%M:%S)"

This was working but not any more. Also, I was under the impression that you can have a command run everytime you receive a mail message based on this .forward file. For example,
\$user, "|~/script.ksh >> ~/tmp/forward.log"

I'm not sure if this is the correct syntax to do this (the syntax is not explicit on the man pages). If anyone has a clue, please advise. Thanks in advance.

Anthony
Wisdom is the principal thing; therefore get wisdom: and with all thy getting get understanding.
6 REPLIES
Christopher Caldwell
Honored Contributor

Re: syntax for .forward file

The syntax for the .forward file is the same as the syntax for the aliases file (man 5 aliases). If something was working, but it's not working now, I'd check to see if sendmails been upgraded lately.

The sendmail folks have gotten security conscious in their old age. I suspect that if you've upgraded to sendmail 8.9.3 (latest on HP I think), you might be getting nailed by the loose permissions.

Specifically, by default sendmail 8.9.3 doesn't like to write to/traverse directories that are group writable. By default, tt also doesn't like group writable .foward files.

To see if this is happening:

/usr/sbin/sendmail:
Copyright (c) 1998 HEWLETT PACKARD COMPANY and its licensors,
including Sendmail, Inc., and the Regents of the
University of California. All rights reserved.
version.c 8.9.3.1 (Berkeley) 2/9/1999 (PHNE_18546)

tail -f /usr/adm/syslog/mail.log [while sending an e-mail to the forward address. sendmail will complain in the log file if it doesn't like the permissions]
Anthony Baldwin
Occasional Advisor

Re: syntax for .forward file

Chris,

The "cat" command is working fine again. The question is, how do you invoke a shell script from the .forward file. Is the syntax that I specified correct? I see the man aliases page, but I have the following on the 2nd line of the .forward file:

\$user, "|~/shell.ksh"

However, when I view the /var/adm/syslog/mail.log I see,

delay=00:00:01, xdelay=00:00:00, mailer=prog, stat=unknown mailer error 1
Apr 9 20:14:48 smell sendmail[15488]: UAA15487: UAA15488: DSN: unknown mailer error

Please advise. Thanks.

Anthony
Wisdom is the principal thing; therefore get wisdom: and with all thy getting get understanding.
Christopher Caldwell
Honored Contributor

Re: syntax for .forward file

-Try full path to the shell script (i.e. /home/blah/myscript.sh).
-make sure that there are no world writeable or group writable directories between / and your script
-make sure the script is not world writable or group writable
-make sure your script returns a proper exit code (see /usr/include/sysexits.h) - exit 0 for success, exit something_else for failure
-make sure your shell is in /etc/shells
Anthony Baldwin
Occasional Advisor

Re: syntax for .forward file

Chris,

I've tried:

\me, "|/users/me/myscript.ksh"

with and without the quotes. This doesn't work. The concept is, that whenever I receive an e-mail, run this script. The syntax seems to be the problem. As stated before:

\me, "|cat > ~/mail_tmp/mail_msg_$(date +%y-%m-%d-%H:%M:%S)"

this works fine. I definitely appreciate your help. Do you have any other suggestions?

Anthony.....
Wisdom is the principal thing; therefore get wisdom: and with all thy getting get understanding.
Christopher Caldwell
Honored Contributor
Solution

Re: syntax for .forward file

Can you include the output of the following commands:

#what /usr/sbin/sendmail
#ll -d /
#ll -d /home
#ll -d /me
#ll myscript.sh
#grep me /etc/passwd
#cat /etc/shells
Anthony Baldwin
Occasional Advisor

Re: syntax for .forward file

Thanks Chris.. I was surpised to find that
the /etc/shells file was missing from the server. I tried it on another server and it worked find. I owe you lunch!!! Thanks again.

Anthony

Wisdom is the principal thing; therefore get wisdom: and with all thy getting get understanding.