我正在尝试通过 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