如何在我的应用程序中检查该信件是否已发送?

时间:2015-07-28 14:27:00

标签: ruby-on-rails ruby sendmail sendgrid

我有一个发送电子邮件的小应用程序。对于发送电子邮件,我使用SendGrid。我有一个用户输入(来自,来自,主体,身体)的表单。一切正常,电子邮件发送。但是,如何在我的应用程序中检查该信件是否已发送?

配置/ development.rb

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
host = 'localhost:3000'
config.action_mailer.default_url_options = { host: host }
ActionMailer::Base.smtp_settings = {
 :address        => 'smtp.sendgrid.net',
 :port           => '587',
 :authentication => :plain,
 :user_name      => ENV['SENDGRID_USERNAME'],
 :password       => ENV['SENDGRID_PASSWORD'],
 :domain         => 'gmail.com',
 :enable_starttls_auto => true
}

应用程序/邮寄者/ send_email.rb

class SendMail < ApplicationMailer

 def welcome(from, to, subject, body)
   @greeting = body

   mail from: from, to: to, subject: subject
 end
end

应用程序/控制器/ send_email_controllers.rb

SendMail.welcome(@from, @to, @subject, @body).deliver_now

谢谢!

0 个答案:

没有答案