Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

is there a way to configure sendmail similar to postfix'



share|improve this question
up vote 4 down vote accepted

Have a look at this milter:

share|improve this answer

You could use MIMEDefang, look for: add_recipient

MIMEDefang is at

share|improve this answer

I was hoping to find a solution that didn't require a milter, but it seems that this is not possible. For just cloning e-mails to a particular mailbox (possibly remote) you could use the milters suggested by others here; I needed to actually create a clone of the SMTP streams to another MTA. The best solution that I found was the mailforward milter. Unfortunately, it didn't seem to work in our Sendmail environment (maybe related to graylisting?)

There's a more complete list of possible solutions at, including the commercial ($90) milter-bcc, but since the milter API provides a mechanism to add envelope recipients (without making any other changes to the message), I was able to just code up a very minimal milter that adds a fixed recipient to all messages, and then accepts them:

 * Sendmail milter to add an additional (bcc) envelope recipient

#include <stdio.h>
#include <stdlib.h>
#include <sysexits.h>
#include <unistd.h>
#include <sys/stat.h>

#include "libmilter/mfapi.h"

#ifndef bool
# define bool   int
# define TRUE   1
# define FALSE  0
#endif /* ! bool */

char *connsock;
char *bcc;

     SMFICTX *ctx;
    if (smfi_addrcpt(ctx, bcc) != MI_SUCCESS)
        fprintf(stderr, "smfi_addrcpt failed\n");
    return SMFIS_ACCEPT;

struct smfiDesc bccfilter =
    "add_bcc",  /* filter name */
    SMFI_VERSION,   /* version code -- do not change */
    SMFIF_ADDRCPT,  /* flags */
    NULL,       /* connection info filter */
    NULL,       /* SMTP HELO command filter */
    NULL,       /* envelope sender filter */
    NULL,       /* envelope recipient filter */
    NULL,       /* header filter */
    NULL,       /* end of header */
    NULL,       /* body block filter */
    bccfi_eom,  /* end of message */
    NULL,       /* message aborted */
    NULL,       /* connection cleanup */
    NULL,       /* unknown SMTP commands */
#endif /* SMFI_VERSION > 2 */
    NULL,       /* DATA command */
#endif /* SMFI_VERSION > 3 */
    NULL        /* Negotiate, at the start of each SMTP connection */
#endif /* SMFI_VERSION > 4 */

static void
    char *prog;
    fprintf(stderr, "Usage: %s SOCKET_PATH BCC_ADDR\n", prog);

main(argc, argv)
     int argc;
     char **argv;
    char *socket;
    bool rmsocket = FALSE;
    struct stat status;

    if (argc != 3)

    socket = argv[1];
    bcc = argv[2];

    if (smfi_setconn(socket) == MI_FAILURE)
        (void) fprintf(stderr, "smfi_setconn failed\n");

    /* attempt to remove existing socket, if possible */
    if (stat(socket, &status) == 0 && S_ISSOCK(status.st_mode))

    if (smfi_register(bccfilter) == MI_FAILURE)
        fprintf(stderr, "smfi_register failed\n");

    return smfi_main();

You still need to compile and install this (along with initscript or systemd unit to start it up before Sendmail after reboots) and configure Sendmail to use this milter, so it's still rather painful compared to the equivalent add_bcc in postfix (or "unseen" router config in Exim), but that's Sendmail for you.

share|improve this answer

Your Answer


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.