I have a rails app on Heroku which can send emails. I added a new feature to send email for a notification. I get this in Heroku logs but no emails are sent.
2016-07-29T19:57:58.895499+00:00 app[web.1]: [ActiveJob] [NotificationBroadcastJob] [40c7b651-3c5d-4308-b8b5-49a142d2930f] Rendered notifications_mailer/new_message.html.erb (226.4ms)
2016-07-29T19:57:58.895630+00:00 app[web.1]: [ActiveJob] [NotificationBroadcastJob] [40c7b651-3c5d-4308-b8b5-49a142d2930f] NotificationsMailer#new_message: processed outbound mail in 246.0ms
2016-07-29T19:57:58.895741+00:00 app[web.1]: [ActiveJob] [NotificationBroadcastJob] [40c7b651-3c5d-4308-b8b5-49a142d2930f] Performed NotificationBroadcastJob from Async(default) in 377.85ms
This is notifications_mailer ruby file app/mailers/notifications_mailer.rb
class NotificationsMailer < ApplicationMailer
def new_message(message)
@message = message
mail(to: message.receiver.email, subject: 'You have a new message')
end
end
This is how I call the new_message action in app/jobs/notifications_broadcast_job.rb
class NotificationBroadcastJob < ApplicationJob
.
.
NotificationsMailer.new_message(personal_message).deliver_now
I use Sendgrid addon and this is from production.rb
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
host = 'www.abcdef.com'
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 => 'www.abcdef.com',
:enable_starttls_auto => true
}
This is my development.rb
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :test
host = 'rails-tutorial-suai.c9.io'
config.action_mailer.default_url_options = { host: host }
config.action_mailer.perform_caching = false
I don't have worker dynos. This is my Procfile.
web: bundle exec puma -C config/puma.rb
Can anyone kindly help? Thanks