I have an app on a server that sends mail via the local system's 'sendmail'. I want to write a program that takes the payload of the message, modifies it, and then sends it on to the original recipients.

I am running sendmail 8.14.4-8 on a Red Hat 6.4 server.

I thought that I could replace the link to /usr/sbin/sendmail with a link to my own script that would do the work and then delegate to the actual sendmail binary.

That didn't seem to work, so next I tried setting up a programmable SMTP server on the same host and tried to get sendmail to relay the messages to it, but sendmail didn't want to relay to any port other than 25. I tried using the following lines:

dnl define(`RELAY_MAILER_ARGS', `TCP $h 8025')dnl
dnl define(`ESMTP_MAILER_ARGS', `TCP $h 8025')dnl

My reading suggested that would work, but sendmail just kept trying port 25.

Anyone have any other ideas how I could approach this problem?

Thanks, Carl

  • 2
    Your first solution -- replacing the system sendmail with a wrapper script -- should have worked just fine. What do you mean by "that didn't seem to work"?
    – larsks
    Commented Jul 25, 2013 at 21:14
  • 1
    Have you thought about implementing a milter to do this?
    – Mike B
    Commented Jul 25, 2013 at 22:41
  • @larsks - When I tested by echoing to the local mail program, I could see the shell script create a temp file, so I knew it worked. When I tried to have the real app send mail, I didn't see a temp file, but I saw the message get processed in /var/log/maillog.
    – Carl
    Commented Jul 25, 2013 at 23:42
  • @Mike B - I am no sendmail expert-- I don't know anything about implementing a filter, but if you pointed me in the right direction, that would be great!
    – Carl
    Commented Jul 25, 2013 at 23:43
  • It sounds as if your application isn't actually calling the sendmail binary. Possibly you have an smtp server listening on localhost and the program is talking to that directly. If that's the case, @MikeB's suggestion of using a milter is a reasonable idea, as is implementing some sort of filtering SMTP proxy server. There are lots of guides out there to both.
    – larsks
    Commented Jul 26, 2013 at 1:10

1 Answer 1


Thanks to @MikeB's suggestion above. I thought 'milter' was a typo, but sendmail mail filters literally are called 'milters'. Go figure. Anyway, i wrote a milter that lets me modify the outgoing message and i must say it was not nearly as dificult as some of the other things I tried.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .