简体   繁体   中英

Mailer not sending emails rails 4

My mailer is not sending anything after waiting and I am not sure why. I've tried deliver_now as well

When I go to the URL http://localhost:3000/send_mail I receive no errors and just a blank page.

my terminal states:

Started GET "/send_mail" for ::1 at 2014-11-18 00:32:39 -0800
Processing by HomeController#send_mail as HTML

ActionMailer::Base#mail: processed outbound mail in 1.2ms

Sent mail to myemail@gmail.com (1.2ms)
Date: Tue, 18 Nov 2014 00:32:39 -0800
From: me@example.com
To: myemail@gmail.com
Message-ID: <546b0427e5677_82b3ffd9e6809bc2363f@MTVL1289dd026.local.mail>
Subject: Contact request
Mime-Version: 1.0
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

test
  Rendered text template (0.0ms)
Completed 200 OK in 4ms (Views: 0.2ms | ActiveRecord: 0.0ms)
::1 - - [18/Nov/2014:00:32:39 -0800] "GET /send_mail HTTP/1.1" 200 - 0.0066

config/environments/development.rb

  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :test
  host = 'localhost:3000'
  config.action_mailer.default_url_options = { host: host }

home controller:

class HomeController < ApplicationController
  def index
  end

  def send_mail
    ActionMailer::Base.mail(:from => "me@example.com", :to => "myemail@gmail.com", :subject => "Contact request", :body => "test").deliver
    render nothing: true
  end
end

routes.rb

match '/send_mail', to: "home#send_mail", via: "get"

I have just copied my code from previous project

  config.action_mailer.default_url_options = { host: 'localhost:3000' }

  config.action_mailer.delivery_method = :smtp
  ActionMailer::Base.smtp_settings = {
    address:              'smtp.gmail.com',
    port:                 587,
    domain:               'gmail.com',
    user_name:            'mailme@gmail.com',
    password:             'pwd',
    authentication:       'plain',
    enable_starttls_auto: true
  }

check out. http://guides.rubyonrails.org/action_mailer_basics.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM