I have Rails application running in Docker, and I want to integrate mailcatcher for development.
docker-compose.yml
version: '3'
services:
db:
image: postgres:alpine
restart: always
volumes:
- postgres-data:/var/lib/postgresql/data
ports:
- "9000:5432"
app:
build:
context: .
dockerfile: ./docker/app/DockerFile
restart: always
command: bash -c "rm -f tmp/pids/server.pid && rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/vsapp-cms-backend
- bundle_path:/bundle
environment:
- BUNDLE_PATH=/bundle/vendor
ports:
- "3002:3000"
depends_on:
- db
mailcatcher:
image: schickling/mailcatcher
ports:
- "1080:1080"
- "1025:1025"
volumes:
bundle_path:
postgres-data:
development.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: '127.0.0.1',
port: 1025
}
I can see the mailcatcher is also running on http://localhost:1080
but when I run UserMailer.send_invite(user).deliver_now!
I'm getting
Errno::ECONNREFUSED: Connection refused - connect(2) for "127.0.0.1" port 1025
I managed to send it by changing the address from development.rb to mailcatcher
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'mailcatcher',
port: 1025
}