Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mailcatcher not working in staging server

I was pretty happy with mailtrap (http://mailtrap.io/) until i found out it got slow. Sometimes it doesn't send email or takes long time.

So thought of alternative and moved to mailcatcher (http://mailcatcher.me/). The issue is, it works fine in development environment but cant made it to work on staging env. Whenever I go for port 1080 to see the mail, path does not finds out.

BTW I am using mailcatcher for my rails app.

Thanks;

[Update] My mailer setting: config.action_mailer.smtp_settings = { :host => http://mydomain.com, :port => 1025 }

BTW when I start mailcatcher daemon process. It logs out

==> smtp://127.0.0.1:1025
==> http://127.0.0.1:1080

Not my actual host, is it the problem ?

like image 930
kxhitiz Avatar asked May 17 '13 12:05

kxhitiz


People also ask

What is MailCatcher?

MailCatcher is a free tool that can intercept emails sent from any web or mobile app. It works as a fake SMTP server where you redirect your messages to instead of sending them to a real SMTP server. Emails sent this way arrive only to a local server and can be viewed in a web interface.

How do I stop MailCatcher?

This will run Mailcatcher in the foreground. You can exit it by hitting Ctrl+C. Local scripts can then connect to SMTP at localhost port 1025 . Additionally, the web interface is available at port 1080 by default.


2 Answers

Normally I would say the answer of Frederick is correct.

However for some reason for us this did not work. Mailcatcher refused to listen on the ip-address. To workaround we just proxied all the traffic through Nginx. Could also be done with another proxy. Anyways, here is our config:

server {
  listen 3020;


  location / {
    proxy_pass http://127.0.0.1:1080;
    proxy_redirect     off;
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
  }

}

You can then access your server like this: myserver.com:3020

Seems a bit of a hack, but hope this helps.

like image 90
Hendrik Avatar answered Oct 06 '22 06:10

Hendrik


By default mailcatcher only runs against the loopback interface (hence the 127.0.0.1 address), so it will only be accessible from the machine it is running on.

You can use the --ip, --smtp-ip, --http-ip options when running mailcatcher to control which ip addresses it binds to.

like image 20
Frederick Cheung Avatar answered Oct 06 '22 07:10

Frederick Cheung