0

We have a need at my work to setup a test email server that will take all mail sent to it for delivery and instead just dump it into an account for later retrieval. I've been out of the email server configuration game long enough that I think that's possible but I don't know for sure.

As a more specific example of what we need: We have code that sends emails to outside clients in certain cases. We want to point our code to a test server that will accept those emails, but not let them get to the outside world (yes, it's happened before, oops). We then need to be able to verify that Email X would have gotten sent to Client Y if we had sent to the real server.

As a bonus, we have a error email alias on our real server that goes to the programmers that we would like to keep getting email from. So anything sent to that alias on the test server would forward to our real server for delivery.

My preference is for postfix but our IT staff seems set on using sendmail (or Exchange) for everything so hints/pointers for either server would be helpful. Thanks a lot.

1

4 Answers 4

2

I think what you want is a mailsink.

You might need to alter somewhat for your specific requirements but I have used something like this to catch user verifications emails.

This procedure uses Postfix and assumes a Redhat-based distro.

  1. If on a local development box, you may need to edit /etc/postfix/main.cf just to get email working at all. i.e.: relayhost = somerelay.isp.net

  2. Edit /etc/postfix/main.cf to include: transport_maps = hash:/etc/postfix/transport

  3. Create or edit /etc/postfix/transport and include: example.com test:

  4. Run: postmap /etc/postfix/transport

  5. Edit /etc/postfix/master.cf to include: test unix - n n - - pipe user=nobody argv=/bin/mail -s Signup [email protected]

  6. service postfix reload

Now signups using an email address of [email protected] will result in an email being sent to [email protected]. From there one can click on the user verification link or inspect the email for content, etc.

So you could add another transport for your outside client emails and send to a local server and use like above to send errors to real server.

Hope this helps.

Cheers

0

have you checked

always_bcc

option in main.cf ?

0

Here's a sendmail solution I found: http://novosial.org/sendmail/discard/

0

I use this to fake the email sending: https://mailtrap.io

Mailtrap is a fake SMTP server for development teams to test, view and share emails sent from the development and staging environments without spamming real customers.

You must log in to answer this question.

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