I'm running a number of virtual servers using vagrant on my computer. This is working well.

I have installed Postfix to send SMTP inside these virtual servers.

But what I want to do is have Postfix send the SMTP to my "real" computer (that the virtual servers are running on), so it can capture the SMTP and display the email for debugging. I currently use smtp4dev to do this, where it can listen to a specific IP and port.

I've tried changing all sorts of things in /etc/postfix/main.cf, including changing various relayhost, mydetination and mynetworks to see if I can 'trick' the virtual smtp server to send it to my "real" computer - but no luck.

Is anyone able to help me achieve this?

  • Please provide more information about what you've tried and how it failed. All you should need to do is configure Postfix in your guest OSes to use your host OS as a relay host. – sciurus Jan 5 '14 at 17:40

Ok - I worked out a solution to this - so I'm posting here in case other people want the solution. It turns out you dont need Postfix at all.

I use SMTP4DEV, but there are many other similar programs that will 'capture' all SMTP emails for instant viewing and easy debugging.

  1. Install your SMTP capture program on your real computer. Have it listen to your real computers own actual IP, on Port 25. In my case my IP was

  2. Fire up vagrant

  3. Test you can ping your "real" computer from within Vagrant - ping

  4. Setup your Dev emails from within your application to something like this


  // This is for Laravel PHP - but you can adapt to suit your own needs
  'driver' => 'smtp',
  'host' => '',   // change to your real computer ip address
  'port' => 25,
  'encryption' => null,

Now when your Vagrant Development box sends an email - it will only go to your 'real' computer and be collected in your SMTP program for instant viewing! And it will never go 'outside' to the real world.

Bonus tip: using this setup means you do not need any MTA/SMTP server setup in your vagrant box - your "real" computer acts as the mail server - so less configuration issues!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.