sendgrid 経由で heroku の ruby on rails アプリからメールを送信しようとしています。これは、テスト メールの送信のみを試みるスタンドアロン アプリです。エラーは出ませんが、メールは送信されません。あなたの助けに感謝します。
== config/environment.rb ===
ActionMailer::Base.smtp_settings = {
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => ENV['SENDGRID_DOMAIN'],
:address => "smtp.sendgrid.net",
:port => 587,
:authentication => :plain,
}
===
==== config/environments/production.rb ===
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
=====
== app/models/notifier.rb ==
class Notifier < ActionMailer::Base
include SendGrid
default from: "abc@yahoo.com"
#sendgrid_category :use_subject_lines
#sengrid_enable :ganalytics, :opentrack
def test_notification
mail(:to => "xyz@gmail.com", :subject => "mail from heroku")
puts("Sent mail from notifier")
end
end
========
heroku コンソールから test_notification メソッドを実行してみました
>> Notifier.test_notification
(これにより、いくつかのログ情報が出力されます..)
#<Mail:Message:279922420, Multipart: false, Headers: <from.., To, Subject, etc).
しかし、send_grid は私のアカウントから送信されたメールを報告しません。メールが届きません。
また、アプリのホームページにアクセスしたときに送信される /home/index/controller から test_notification を呼び出して、別の方法でメールを送信しようとしました。
===
class HomeController < ApplicationController
def index
Notifier.test_notification()
end
end
===
統計は、メールが送信済みであることも報告しません。どんな助けでも大歓迎です。
ありがとう!DS