title: Rails Action Mailer with Devise
body: <p>I understand this has been asked before and I've been following Rails ActionMailer Guides as well as looking through a few related questions on stackoverflow. I'm running a localhost and trying to send emails from there. From the rails guides, I followed every step and double checked everything is written as in the guides. I've also read a few questions found here, but still my emails aren't sending from localhost. Also, I'm not getting any errors within my server.</p>
  
  <p>config/environments/development.rb</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
  
    #Mailers
    config.action_mailer.delivery_method = :sendmail
    config.action_mailer.perform_deliveries = true
    config.action_mailer.raise_delivery_errors = true
    config.action_mailer.default_options = {from: 'dogseeker7@gmail.com'}
  
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
      address:              'smtp.gmail.com',
      port:                 587,
      domain:               'localhost:3000',
      user_name:            ENV["ADMIN_EMAIL"],                                                                                                                   
      password:             ENV["DOG_SEEKER_GMAIL"],
      authentication:       'plain',
      enable_starttls_auto: true
  }
  </code></pre>
  
  <p>mailers/admin_mailer.rb</p>
  
  <pre><code>Class AdminMailer &lt; Devise::Mailer
  helper :application
  include Devise::Controllers::UrlHelpers    
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <pre><code>def welcome_email(admin)                                                                                                                                
      @admin = admin
      @login_url = "localhost:3000/admins/sign_in"
      mail(to: @admin.email, subject: "Welcome to Dog Seeker!")
  end
  </code></pre>
  
  <p>app/admin/admin_controllers.rb</p>
  
  <pre><code>def create
     @admin = Admin.new(params[:admin])
  
     respond_to do |format|
       if @admin.save
         AdminMailer.welcome_email(@admin).deliver_now
         format.html { redirect_to(@admin, notice: 'Admin was successfully created.') }
         format.json { render json: @admin, status: :created, location: @admin }
       else
         format.html { redirect_to new_admin_registration_path }
         format.json { render json: @admin.errors, status: :unprocessable_entity }
       end
     end
   end
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Log when new admin Signs Up</p>
  
  <pre><code>Started POST "/admins" for 127.0.0.1 at 2017-08-05 22:09:15 -0700
  Processing by Devise::RegistrationsController#create as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"&lt;token&gt;==", "admin"=&gt;{"email"=&gt;"stenglinephoto@gmail.com", "password"=&gt;"[FILTERED]", "password_confirmation"=&gt;"[FILTERED]"}, "commit"=&gt;"Sign up"}
     (0.2ms)  BEGIN
    Admin Exists (0.6ms)  SELECT  1 AS one FROM "admins" WHERE "admins"."email" = $1 LIMIT $2  [["email", "stenglinephoto@gmail.com"], ["LIMIT", 1]]
    SQL (0.6ms)  INSERT INTO "admins" ("email", "encrypted_password", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"  [["email", "stenglinephoto@gmail.com"], ["encrypted_password", "&lt;password&gt;"], ["created_at", "2017-08-06 05:09:15.904920"], ["updated_at", "2017-08-06 05:09:15.904920"]]
     (2.0ms)  COMMIT
     (0.1ms)  BEGIN
    SQL (0.5ms)  UPDATE "admins" SET "sign_in_count" = $1, "current_sign_in_at" = $2, "last_sign_in_at" = $3, "current_sign_in_ip" = $4, "last_sign_in_ip" = $5, "updated_at" = $6 WHERE "admins"."id" = $7  [["sign_in_count", 1], ["current_sign_in_at", "2017-08-06 05:09:15.909337"], ["last_sign_in_at", "2017-08-06 05:09:15.909337"], ["current_sign_in_ip", "127.0.0.1/32"], ["last_sign_in_ip", "127.0.0.1/32"], ["updated_at", "2017-08-06 05:09:15.909955"], ["id", 29]]
     (0.5ms)  COMMIT
  Redirected to http://localhost:3000/
  Completed 302 Found in 172ms (ActiveRecord: 4.5ms)
  
  
  Started GET "/" for 127.0.0.1 at 2017-08-05 22:09:15 -0700
  Processing by HomepagesController#index as HTML
    Rendering homepages/index.html.erb within layouts/application
    Rendered homepages/index.html.erb within layouts/application (0.5ms)
    Admin Load (0.7ms)  SELECT  "admins".* FROM "admins" WHERE "admins"."id" = $1 ORDER BY "admins"."id" ASC LIMIT $2  [["id", 29], ["LIMIT", 1]]
    Rendered shared/_header.html.erb (5.5ms)
    Rendered shared/_main.html.erb (1.0ms)
  Completed 200 OK in 18ms (Views: 16.2ms | ActiveRecord: 0.7ms)
  </code></pre>
  
  <p><strong>Another update</strong></p>
  
  <p>I have another mailer that gets sent when a dog is created and that works fine from localhost and with all the above configurations. My guess is the reason that mailers won't send when an admin account is created is due to the devise registrations controller overriding my controller. In other words, it's not hitting my create action in the admin_controller, but is hitting the registration within devises registration controller.</p>
  
  <p>Please let me know if you need additional information.</p>