diff --git a/Gemfile b/Gemfile index af4e7a8e1..5b230f78d 100644 --- a/Gemfile +++ b/Gemfile @@ -48,6 +48,9 @@ gem 'request_store' gem 'elasticsearch-model' gem 'elasticsearch-rails' + +gem 'mailgun-ruby' + # needed for looser jpeg header compat gem 'ruby-imagespec', :require => "image_spec", :git => "https://github.com/r888888888/ruby-imagespec.git", :branch => "exif-fixes" diff --git a/Gemfile.lock b/Gemfile.lock index 3a9dbbc80..29a0a2c88 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -186,6 +186,8 @@ GEM nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) + mailgun-ruby (1.2.0) + rest-client (~> 2.0.2) marcel (0.3.3) mimemagic (~> 0.3.2) mechanize (2.7.6) @@ -229,6 +231,7 @@ GEM net-sftp (2.1.2) net-ssh (>= 2.6.5) net-ssh (5.2.0) + netrc (0.11.0) newrelic_rpm (6.5.0.357) nio4r (2.5.1) nokogiri (1.10.4) @@ -304,6 +307,15 @@ GEM responders (3.0.0) actionpack (>= 5.0) railties (>= 5.0) + rest-client (2.0.2) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + rest-client (2.0.2-x64-mingw32) + ffi (~> 1.9) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) retriable (3.1.2) ruby-vips (2.0.14) ffi (~> 1.9) @@ -431,6 +443,7 @@ DEPENDENCIES httparty jquery-rails listen + mailgun-ruby mechanize memoist minitest-ci diff --git a/app/mailers/maintenance/user/email_confirmation_mailer.rb b/app/mailers/maintenance/user/email_confirmation_mailer.rb index ab4eb9c1b..8784f23f4 100644 --- a/app/mailers/maintenance/user/email_confirmation_mailer.rb +++ b/app/mailers/maintenance/user/email_confirmation_mailer.rb @@ -3,10 +3,11 @@ module Maintenance class EmailConfirmationMailer < ActionMailer::Base add_template_helper ApplicationHelper add_template_helper UsersHelper + default :from => Danbooru.config.mail_from_addr, :content_type => "text/html" def confirmation(user) @user = user - mail(:to => @user.email, :subject => "#{Danbooru.config.app_name} account confirmation", :from => Danbooru.config.contact_email) + mail(:to => @user.email, :subject => "#{Danbooru.config.app_name} account confirmation") end end end diff --git a/app/mailers/maintenance/user/login_reminder_mailer.rb b/app/mailers/maintenance/user/login_reminder_mailer.rb index 42debd272..323cfc4e6 100644 --- a/app/mailers/maintenance/user/login_reminder_mailer.rb +++ b/app/mailers/maintenance/user/login_reminder_mailer.rb @@ -1,10 +1,12 @@ module Maintenance module User class LoginReminderMailer < ActionMailer::Base + default :from => Danbooru.config.mail_from_addr, :content_type => "text/html" + def notice(user) @user = user if user.email.present? - mail(:to => user.email, :subject => "#{Danbooru.config.app_name} login reminder", :from => Danbooru.config.contact_email) + mail(:to => user.email, :subject => "#{Danbooru.config.app_name} login reminder") end end end diff --git a/app/mailers/maintenance/user/password_reset_mailer.rb b/app/mailers/maintenance/user/password_reset_mailer.rb index 57a1c0ff5..8726c3b50 100644 --- a/app/mailers/maintenance/user/password_reset_mailer.rb +++ b/app/mailers/maintenance/user/password_reset_mailer.rb @@ -1,10 +1,12 @@ module Maintenance module User class PasswordResetMailer < ActionMailer::Base + default :from => Danbooru.config.mail_from_addr, :content_type => "text/html" + def reset_request(user, nonce) @user = user @nonce = nonce - mail(:to => @user.email, :subject => "#{Danbooru.config.app_name} password reset", :from => Danbooru.config.contact_email) + mail(:to => @user.email, :subject => "#{Danbooru.config.app_name} password reset") end end end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 00bdab9dc..30c65f6df 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -1,7 +1,7 @@ class UserMailer < ActionMailer::Base add_template_helper ApplicationHelper add_template_helper UsersHelper - default :from => Danbooru.config.contact_email, :content_type => "text/html" + default :from => Danbooru.config.mail_from_addr, :content_type => "text/html" def dmail_notice(dmail) @dmail = dmail diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index 2dba52967..d74066283 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -767,6 +767,18 @@ fart' "zDMSATq0W3hmA5p3rKTgD" end + def mailgun_api_key + '' + end + + def mailgun_domain + '' + end + + def mail_from_addr + 'noreply@localhost' + end + # impose additional requirements to create tag aliases and implications def strict_tag_requirements true diff --git a/config/environments/production.rb b/config/environments/production.rb index bffa76888..42f5b1f0c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -62,6 +62,12 @@ Rails.application.configure do config.action_mailer.perform_caching = false + config.action_mailer.delivery_method = :mailgun + config.action_mailer.mailgun_settings = { + api_key: Danbooru.config.mailgun_api_key, + domain: Danbooru.config.mailgun_domain + } + # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false