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?
You can do that in sendmail by modifying rule set 0. Edit your /etc/mail/sendmail.mc to include (at the bottom):
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:
Where bit-bucket is an alias defined in /etc/mail/aliases:
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
.If "intended recipients" have countable amount, use aliases or virtusertable to intercept messages and deliver locally