Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like all mail sent to a particular alias on a Linux machine to be processed by a perl script but sendmail is giving me a "Service unavailable" error and I don't understand what I'm missing.

I created my handle_email.pl script (right now, this just prints its parameters to /tmp/email.txt) and added a symbolic link to it in /etc/smrsh.

Then I added this to /etc/aliases:

mailtest: |handle_email.pl

and ran newaliases afterwards. Note that I've also tried mailtest: |/etc/smrsh/handle_email.pl which gave the same results. I've also tried copying the actual script into /etc/smrsh rather than a link, same results again.

When I send mail to the mailtest alias, the file in /tmp never gets created, and I get this in /var/log/maillog:

Nov  1 14:43:59 localhost sendmail[24839]: qA1IhwHm024839: from=<xxx@xxx>, size=284, class=0, nrcpts=1, msgid=<201211011843.qA1IhwHm024839@localhost.localdomain>, proto=ESMTP, daemon=MTA, relay=[10.7.160.180]
Nov  1 14:43:59 localhost smrsh: uid 8: attempt to use "handle_email.pl"
Nov  1 14:43:59 localhost sendmail[24850]: qA1IhwHm024839: to=|handle_email.pl, ctladdr=<mailtest@xxx> (8/0), delay=00:00:00, xdelay=00:00:00, mailer=prog, pri=30570, dsn=5.0.0, stat=Service unavailable
Nov  1 14:43:59 localhost sendmail[24850]: qA1IhwHm024839: qA1IhxHm024850: DSN: Service unavailable
Nov  1 14:44:00 localhost sendmail[24850]: qA1IhxHm024850: to=<xxx@xxx>, delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=31594, relay=sy-int-mx.xxx. [<IP addr>], dsn=2.0.0, stat=Sent (qA1Ii4127508 Message accepted for delivery)

I get an email message describing the failure, which says:

The original message was received at Thu, 1 Nov 2012 14:58:16 -0400
from [<ip address>]

   ----- The following addresses had permanent fatal errors -----
|/etc/smrsh/handle_email.pl
    (reason: Service unavailable)
    (expanded from: <mailtest@xxx>)

   ----- Transcript of session follows -----
smrsh: "handle_email.pl" not available for sendmail programs
554 5.0.0 Service unavailable

Why will smrsh not execute my script?

Update: Answering questions in comments.

I've copied the script to /etc/smrsh and removed the link. The file permissions are 0700 (also tried 0755) and the first line is #!/usr/local/bin/perl which is correct. There is only one file in /etc/smrsh. The ls -l output:

[main:g:64] xxx:/etc/smrsh# ls -l
total 4
-rwx------. 1 root root 281 Nov  1 16:35 handle_email.pl
share|improve this question
    
What are the permissions on handle_email.pl? –  mdpc Nov 1 '12 at 19:38
    
Does the handle_email.pl program first line have the appropriate and functional path to the PERL program? –  mdpc Nov 1 '12 at 19:42
    
Also you might want to include the ls -l of /etc/smrsh directory. –  mdpc Nov 1 '12 at 19:43
    
@mdpc Thanks for your responses - I've updated the question with the answers. –  Graeme Perrow Nov 1 '12 at 20:43
    
First disable FEATURE(smrsh) from your sendmail.mc, rebuild sendmail.cf and restart sendmail. Then test whether your script works. If it does, or when it does, then come back and make it work with smrsh. But first check whether it works without it. –  adamo Nov 3 '12 at 8:13
show 1 more comment

1 Answer

Try changing the permission of /etc/smrsh/handle_email.pl to 755 and I think you'll have more success. You might want to restart sendmail just to be sure things are properly initialized and configured.

share|improve this answer
    
Thanks, but nope. Tried changing permissions and restarting sendmail, same result. –  Graeme Perrow Nov 1 '12 at 21:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.