Skip to content

Instantly share code, notes, and snippets.

@sutonea
Created February 8, 2025 07:38
Show Gist options
  • Save sutonea/398df1499d5903b2ca36ea3598384bb5 to your computer and use it in GitHub Desktop.
Save sutonea/398df1499d5903b2ca36ea3598384bb5 to your computer and use it in GitHub Desktop.
Ruby on rails と Conoha メールサーバーで 接続するサンプル設定ファイル
# Mail delivery settings
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address: ENV.fetch('SMTP_ADDRESS', 'mail73.conoha.ne.jp'),
  port: ENV.fetch('SMTP_PORT', '587').to_i,
  domain: ENV.fetch('SMTP_DOMAIN', 'mail73.conoha.ne.jp'),
  user_name: ENV.fetch('SMTP_USERNAME', 'ichiro@example.conoha.email'),
  password: ENV.fetch('SMTP_PASSWORD', '1234ABCD'),
  authentication: ENV.fetch('SMTP_AUTHENTICATION', 'login'),
  enable_starttls_auto: ENV.fetch('SMTP_ENABLE_STARTTLS_AUTO', 'true') == 'true'
}

# Raise errors if the mailer can't send.
config.action_mailer.logger = Logger.new('log/development_mail.log', 'weekly')
config.action_mailer.raise_delivery_errors = true

# Make template changes take effect immediately.
config.action_mailer.perform_caching = false

# Set host to be used by links generated in mailer templates.
config.action_mailer.default_url_options = {
  host: ENV.fetch('MAILER_HOST', 'localhost'),
  port: ENV.fetch('MAILER_PORT', '3000').to_i
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment