Skip to content

Commit b5b05c5

Browse files
committed
Moving to mailgun
1 parent 1cd11dd commit b5b05c5

File tree

7 files changed

+23
-341
lines changed

7 files changed

+23
-341
lines changed

app/mailers/application_mailer.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
class ApplicationMailer < ActionMailer::Base
2-
default from: "[email protected]"
32
layout "mailer"
43
end

app/mailers/user_mailer.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
class UserMailer < ApplicationMailer
2-
default from: ENV.fetch('MAIL_FROM', 'no-reply@localhost')
3-
42
def verification_email(token, raw)
53
@token_url = verification_url(token: raw)
64
mail to: token.email, subject: 'Verify your email'

config/environments/production.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,29 @@
5757

5858
# Raise delivery errors in production
5959
config.action_mailer.raise_delivery_errors = true
60+
config.action_mailer.perform_deliveries = true
6061
config.action_mailer.delivery_method = :smtp
6162

6263
# Set host to be used by links generated in mailer templates.
6364
config.action_mailer.default_url_options = {
64-
host: ENV.fetch("APP_HOST", "example.com"),
65+
host: ENV.fetch("APP_HOST", "hackorum.dev"),
6566
protocol: "https"
6667
}
6768

6869
# Default from address for all mailers
6970
config.action_mailer.default_options = {
70-
from: ENV.fetch("MAIL_FROM", "noreply@example.com")
71+
from: ENV.fetch("MAIL_FROM", "noreply@hackorum.dev")
7172
}
7273

73-
# SMTP server configuration
74+
# SMTP server configuration (Mailgun)
7475
config.action_mailer.smtp_settings = {
75-
address: ENV.fetch("SMTP_ADDRESS", "mail"),
76+
address: ENV.fetch("SMTP_ADDRESS", "smtp.eu.mailgun.org"),
7677
port: ENV.fetch("SMTP_PORT", "587").to_i,
77-
domain: ENV.fetch("SMTP_DOMAIN", "example.com"),
78-
# No authentication needed for internal mail server
79-
authentication: nil,
80-
enable_starttls_auto: false,
81-
openssl_verify_mode: "none"
78+
domain: ENV.fetch("SMTP_DOMAIN", "hackorum.dev"),
79+
user_name: ENV.fetch("SMTP_USERNAME"),
80+
password: ENV.fetch("SMTP_PASSWORD"),
81+
authentication: :plain,
82+
enable_starttls_auto: true
8283
}
8384

8485
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to

deploy/.env.example

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,17 @@ GOOGLE_REDIRECT_URI=https://hackorum.example.com/auth/google_oauth2/callback
2929
# Hostname for Caddy (update deploy/Caddyfile too)
3030
APP_HOST=hackorum.example.com
3131

32-
# Mail configuration
33-
MAIL_DOMAIN=example.com
34-
MAIL_HOSTNAME=mail.example.com
35-
36-
DKIM_SELECTOR=mail
37-
38-
# Optional: Use a relay host (e.g., SendGrid, Mailgun) instead of direct sending
39-
# This is recommended for better deliverability
40-
# MAIL_RELAYHOST=[smtp.sendgrid.net]:587
41-
# MAIL_RELAYHOST_USERNAME=apikey
42-
# MAIL_RELAYHOST_PASSWORD=your-sendgrid-api-key
43-
44-
# SMTP settings for Rails
45-
SMTP_ADDRESS=mail
32+
# Mail configuration via Mailgun
33+
# Sign up at https://mailgun.com and verify your domain (use subdomain mg.example.com)
34+
# Get credentials from Mailgun dashboard → Sending → Domain settings → SMTP credentials
35+
MAIL_DOMAIN=mg.example.com
36+
37+
38+
# Mailgun SMTP settings
39+
# EU region (GDPR compliant): smtp.eu.mailgun.org
40+
# US region: smtp.mailgun.org
41+
SMTP_ADDRESS=smtp.eu.mailgun.org
4642
SMTP_PORT=587
47-
SMTP_DOMAIN=example.com
43+
SMTP_DOMAIN=hackorum.dev
44+
SMTP_USERNAME=[email protected]
45+
SMTP_PASSWORD=your-mailgun-smtp-password

deploy/docker-compose.yml

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -102,54 +102,6 @@ services:
102102
- /var/run/docker.sock:/var/run/docker.sock
103103
restart: unless-stopped
104104

105-
mail:
106-
image: boky/postfix:latest
107-
hostname: ${MAIL_HOSTNAME:-mail.example.com}
108-
environment:
109-
# Domain from which emails will be sent
110-
ALLOWED_SENDER_DOMAINS: ${MAIL_DOMAIN:-example.com}
111-
112-
# Relay host (leave empty for direct sending, or use a relay like SendGrid/Mailgun)
113-
# RELAYHOST: ${MAIL_RELAYHOST:-}
114-
# RELAYHOST_USERNAME: ${MAIL_RELAYHOST_USERNAME:-}
115-
# RELAYHOST_PASSWORD: ${MAIL_RELAYHOST_PASSWORD:-}
116-
117-
# DKIM signing
118-
DKIM_SELECTOR: ${DKIM_SELECTOR:-mail}
119-
DKIM_AUTOGENERATE: "true"
120-
121-
# Logging
122-
LOG_LEVEL: ${MAIL_LOG_LEVEL:-info}
123-
124-
# Override from address (optional, for testing)
125-
# OVERWRITE_FROM: ${MAIL_OVERWRITE_FROM:-}
126-
127-
# TLS configuration
128-
TLS: "true"
129-
130-
# Allow localhost relay (for the web container)
131-
ALLOW_EMPTY_SENDER_DOMAINS: "false"
132-
133-
# Message size limit (default 10MB)
134-
MESSAGE_SIZE_LIMIT: ${MAIL_MESSAGE_SIZE_LIMIT:-10240000}
135-
volumes:
136-
# Persist DKIM keys
137-
- mail_dkim:/etc/opendkim/keys
138-
# Persist mail queue
139-
- mail_spool:/var/spool/postfix
140-
expose:
141-
- "587" # Submission port (for authenticated clients)
142-
ports:
143-
- "25:25" # SMTP port (for receiving mail)
144-
healthcheck:
145-
test: ["CMD-SHELL", "postfix status || exit 1"]
146-
interval: 30s
147-
timeout: 10s
148-
retries: 3
149-
restart: unless-stopped
150-
labels:
151-
autoheal: "true"
152-
153105
psql:
154106
image: postgres:18
155107
entrypoint: ["psql", "postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-hackorum}"]
@@ -165,5 +117,3 @@ volumes:
165117
pgbackups:
166118
caddy_data:
167119
caddy_config:
168-
mail_dkim:
169-
mail_spool:

deploy/get-dkim-key.sh

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)