/etc/aliases using pipe to run script return error (mailer=prog, dsn=5.3.0, stat=unknown mailer error 2)
Question: I would like to get any advice for my issue to run script on /etc/aliases. At
first, here are my envirements/script.

  * OS : centos 6
  * script : python 2.6.6
  * mail : sendmail-8.14 / dovecot-2x
  * python script (it's very simple for testing)

> import sys
>
> f = open("aa.txt", 'w')
>
> for i in range(1, 5): data = "%d \n" % i f.write(data)
>
> f.close() sys.exit()

and then I did some congiguration to use smrsh like, make link on /etc/smrsh/,
move script on /etc/smrsh/...

and then modified the /etc/aliases as below:

    
    
    testuser:  "|/etc/smrsh/python /etc/smrsh/aa.py"
    

and then run `newaliases`.

When I send email to testuser user, maillog shows error as below: (sorry for
changing some info like IP, domain)

    
    
    Mar 13 11:14:38 localhost sendmail[8153]: s2DBEcX7008153: from=<ttt@test.com>, size=4448, class=0, nrcpts=1, msgid=<B75C8C1216C9824DBF46410575577E294559AC17@test.com>, proto=ESMTP, daemon=MTA, relay=relay.test.com [xx.xxx.000.xx]
    Mar 13 11:14:39 localhost sendmail[8154]: s2DBEcX7008153: to="|/etc/smrsh/python /etc/smrsh/aa.py", ctladdr=<testuser@[xx.xx.xx.xx]> (8/0), delay=00:00:01, xdelay=00:00:01, mailer=prog, pri=34652, dsn=5.3.0, stat=unknown mailer error 1
    Mar 13 11:14:39 localhost sendmail[8154]: s2DBEcX7008153: s2DBEdX7008154: DSN: unknown mailer error 1
    

but, just forwarding email via /etc/aliases works very well like, testuser :
test@zzz.com

I tried to run with smrsh on the shell :

> > smrsh -c "|/etc/smrsh/python /etc/smrsh/aa.py"

it also works very well.

here are my sendmail.cf for Mprog,

    
    
    Mlocal,         P=/usr/bin/procmail, F=lsDFMAw5:/|@qSPfhn9, S=EnvFromL/HdrFromL, R=EnvToL/HdrToL,
                    T=DNS/RFC822/X-Unix,
                    A=procmail -t -Y -a $h -d $u
    Mprog,          P=/usr/sbin/smrsh, F=lsDFMoqeu9, S=EnvFromL/HdrFromL, R=EnvToL/HdrToL, D=$z:/,
                    T=X-Unix/X-Unix/X-Unix,
                    A=smrsh -c $u
    

and, /etc/smrsh/

    
    
    lrwxrwxrwx.  1 root root   17 Mar 13 09:01 procmail -> /usr/bin/procmail
    lrwxrwxrwx.  1 root root   15 Mar 13 09:08 python -> /usr/bin/python
    lrwxrwxrwx.  1 root root   15 Mar 13 09:42 smrsh -> /usr/sbin/smrsh
    lrwxrwxrwx.  1 root root   17 Feb 13 09:17 vacation -> /usr/bin/vacation
    -rwxr-xr-x.  1 root root  125 Mar 13 11:27 aa.py
    -rw-r--r--.  1 root root   12 Mar 13 11:27 aa.txt
    

Could someone help to slove this problem? Many Thanks!


Answer: # [Sendmail FAQ 4.13 : What does "unknown mailer error 1"
mean?](http://www.sendmail.com/sm/open_source/support/support_faq/general_issues_faq/#4.13)

Sendmail expects exit code zero (0) to signal all "OK" **OR** exit codes from
64 to 78 to signal specific problems. In your case is not on the list of exit
codes sendmail can interpret.

Valid exit codes to signal errors/problems are listed in
[`sysexits.h`](https://www.freebsd.org/cgi/man.cgi?query=sysexits&apropos=0&sektion=0&manpath=FreeBSD%204.3-RELEASE&format=html)

    
    
    #define EX_USAGE        64      /* command line usage error */
    #define EX_DATAERR      65      /* data format error */
    #define EX_NOINPUT      66      /* cannot open input */
    #define EX_NOUSER       67      /* addressee unknown */
    #define EX_NOHOST       68      /* host name unknown */
    #define EX_UNAVAILABLE  69      /* service unavailable */
    #define EX_SOFTWARE     70      /* internal software error */
    #define EX_OSERR        71      /* system error (e.g., can't fork) */
    #define EX_OSFILE       72      /* critical OS file missing */
    #define EX_CANTCREAT    73      /* can't create (user) output file */
    #define EX_IOERR        74      /* input/output error */
    #define EX_TEMPFAIL     75      /* temp failure; user is invited to retry */
    #define EX_PROTOCOL     76      /* remote error in protocol */
    #define EX_NOPERM       77      /* permission denied */
    #define EX_CONFIG       78      /* configuration error */
    

