Sign inSign up

ngahq1310/mailserver

By ngahq1310

•Updated 3 months ago

Image
0

162

ngahq1310/mailserver repository overview

⁠Dùng image trong docker-compose của project

services:
  mailserver:
    image: ngahq1310/mailserver:latest
    ports:
      - "2525:2525"
      - "3000:3000"
    environment:
      DB_PATH: /data/emails.db
    volumes:
      - mailserver-data:/data
    restart: unless-stopped

  app:
    depends_on:
      - mailserver

volumes:
  mailserver-data:

⁠Endpoint mặc định:

  • SMTP: localhost:2525
  • Web UI: http://127.0.0.1:3000

⁠Setting FastAPI

⁠Biến môi trường (.env)
MAIL_SERVER=mailserver
MAIL_PORT=2525
MAIL_FROM=noreply@localhost
MAIL_STARTTLS=false
MAIL_SSL_TLS=false
MAIL_USE_CREDENTIALS=false
⁠Gửi mail bằng smtplib
import smtplib
from email.message import EmailMessage

def send_test_email(to: str):
    msg = EmailMessage()
    msg["From"] = "noreply@localhost"
    msg["To"] = to
    msg["Subject"] = "Test email"
    msg.set_content("Hello from FastAPI")

    with smtplib.SMTP("mailserver", 2525, timeout=5) as smtp:
        smtp.send_message(msg)

⁠Setting Rails

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:         "mailserver",
  port:            2525,
  domain:          "localhost:3001",
  enable_starttls: false,
  open_timeout:    5,
  read_timeout:    5,
}

Tag summary

Content type

Image

Digest

sha256:b160bf1bf…

Size

169.3 MB

Last updated

3 months ago

docker pull ngahq1310/mailserver