Obviously I’m in a need of such an installation, otherwise I wouldn’t have googled about this (btw.: Do you know lmgtfy.com).

Here are some snippets from:

  1. ChrizDee
  2. Craig Ambrose

And? What did I do:

I first enabled Postfix using 1). After this I have changed /etc/aliases:

[sourcecode language=’ruby’]

echo ‘rails_mailer: “|/usr/local/bin/mail_handler.rb”‘ >> /etc/aliases
chmod 755 /usr/local/bin/mail_handler.rb”‘ >> /etc/aliases
sudo newaliases
sudo postfix reload

[/sourcecode]

[sourcecode language=’ruby’]
#!/usr/bin/ruby
require ‘net/http’
require ‘uri’Net::HTTP.post_form URI.parse(‘http://localhost:3000/emails’), { “email” => STDIN.read }

[/sourcecode]

The script above will be triggered by every mail that will be sent to rails_mailer@localhost (resp. your hostname). It will put a post-request to localhost:3000/email including the email in the parameter “email”.