Skip to content

Instantly share code, notes, and snippets.

@hilkeheremans
Last active February 9, 2026 11:39
Show Gist options
  • Select an option

  • Save hilkeheremans/bcd25ac2b1ebba50001f40de3ebfd920 to your computer and use it in GitHub Desktop.

Select an option

Save hilkeheremans/bcd25ac2b1ebba50001f40de3ebfd920 to your computer and use it in GitHub Desktop.
Mailpit - Slightly more secure development deployment for Coolify
# Default Coolify provides zero encryption/security which I don't like
# Use this template, be sure to point the service in coolify to the correct link just before deploy, eg `https://mailpit.yourdomain.com:8025`
# (also configure your DNS obv)
# After that Coolify should make this available at https://mailpit.yourdomain.com, with STARTTLS SMTP on port 587
version: '3.8'
services:
mailpit:
image: 'axllent/mailpit:latest'
container_name: mailpit
restart: unless-stopped
ports:
- '587:587'
environment:
MP_SMTP_AUTH: '${MAILPIT_USERNAME:-admin}:${MAILPIT_PASSWORD:-change_me}'
MP_UI_AUTH: '${MAILPIT_USERNAME:-admin}:${MAILPIT_PASSWORD:-change_me}'
MP_SMTP_TLS_CERT: 'sans:localhost'
MP_SMTP_TLS_KEY: 'sans:localhost'
MP_SMTP_REQUIRE_STARTTLS: 1
MP_SMTP_BIND_ADDR: '0.0.0.0:587'
MP_MAX_MESSAGES: 5000
MP_DATABASE: /data/mailpit.db
volumes:
- 'mailpit-data:/data'
healthcheck:
test:
- CMD
- /mailpit
- readyz
interval: 5s
timeout: 20s
retries: 10
volumes:
mailpit-data:
const nodemailer = require('nodemailer');
// Configuration
const config = {
host: 'mailpit.yourdomain.com', // or 'localhost' if testing locally
port: 587,
secure: false, // true for port 465, false for other ports (STARTTLS)
auth: {
user: 'admin',
pass: 'change_me'
},
// For self-signed certificates or development
tls: {
rejectUnauthorized: false // Set to true in production with valid certs
}
};
// Create transporter
const transporter = nodemailer.createTransport(config);
// Email options
const mailOptions = {
from: '"Test Sender" <sender@example.com>',
to: 'recipient@example.com',
subject: 'Test Email from Mailpit SMTP',
text: 'This is a plain text test email.',
html: '<h1>Test Email</h1><p>This is an <strong>HTML</strong> test email sent via Mailpit SMTP with STARTTLS.</p>'
};
// Send email
async function sendTestEmail() {
try {
console.log('Sending test email...');
console.log('Config:', {
host: config.host,
port: config.port,
secure: config.secure,
user: config.auth.user
});
const info = await transporter.sendMail(mailOptions);
console.log('✓ Email sent successfully!');
console.log('Message ID:', info.messageId);
console.log('Response:', info.response);
console.log('\nCheck your Mailpit web UI at: https://mailpit.yourdomain.com');
} catch (error) {
console.error('✗ Error sending email:', error);
}
}
sendTestEmail();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment