簡體   English   中英

郵件程序未發送電子郵件rails 4

[英]Mailer not sending emails rails 4

我的郵件發送程序在等待后沒有發送任何內容,我不確定為什么。 我也嘗試了deliver_now

當我轉到URL http://localhost:3000/send_mail我沒有收到任何錯誤,而只是收到空白頁面。

我的終端指出:

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

配置/環境/ 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 }

家庭控制器:

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"

我剛剛從上一個項目復制了我的代碼

  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
  }

查看。 http://guides.rubyonrails.org/action_mailer_basics.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM