0

Is it possible to configure sendmail to accept all outbound email but to not send it out? Either it can just log them to be read later, or better yet, if it can be configured to send ALL outbound mail to a preconfigured recipient (regardless of what is specified in the email).

We work on developing applications for e-commerce. Our development environments are Ubuntu Desktop (11.10).

We run a full application stack locally on each desktop - web server, application server, database etc.

Our application sends out email when certain events occur.

We do not actually want the email to be sent to the intended recipient, because this is not from a production environment.

We would like the application to think that the sending of email has been successful.

We would like to see the email, post-facto, that gets sent out.

Note, we are on Ubuntu. If not sendmail, then maybe some other mail server?

Vihung
  • 111
  • 1
  • 5

2 Answers2

1

You can do that in sendmail by modifying rule set 0. Edit your /etc/mail/sendmail.mc to include (at the bottom):

LOCAL_RULE_0 
R$* < @ $=w . > $*       $#local $: $1
R$* < @ $* . > $*        $#local $: user

Rule set 0 selects a delivery agent for each recipient. The first line checks whether the recipient is a local user. If the recipient is a local user then the right hand side of the email address is included in class $=w then the recipient is considered local and the checks stop. If it is not included, then the mail is delivered to local user user (you may change this to any user of the system you like).

If you want to discard instead of delivering to user change the second line to:

R$* < @ $* . > $*        $#local $: bit-bucket

Where bit-bucket is an alias defined in /etc/mail/aliases:

bit-bucket: /dev/null

Do not forget to run newaliases after editing the /etc/mail/aliases file. Note: You cannot use $#discard in rule set 0.

Do not copy-paste the above code snippet. The left hand side and the right hand side of the rules are separated with tabs, not spaces. So it is better to type it in yourself.

After editing sendmail.mc you have to produce sendmail.cf and then restart the sendmail daemon. On Debian systems this is done by running sendmailconfig.

adamo
  • 6,867
  • 3
  • 29
  • 58
0

If "intended recipients" have countable amount, use aliases or virtusertable to intercept messages and deliver locally

Lazy Badger
  • 3,067
  • 14
  • 13
  • This is OK for incoming email, but does not work for email that is supposed to be sent from this server, and he wants that captured too. – adamo Mar 02 '12 at 15:58
  • Mea culpa, forgot. nullclient or generictable maybe? I **hate** direct hacking of mc – Lazy Badger Mar 02 '12 at 16:10
  • Unfortunately, _FEATURE(genericstable)_ transforms senders' addresses. – adamo Mar 02 '12 at 19:17