5

I'm attempting to send mail from ruby on rails app on heroku via sendgrid. This is a standalone app only trying to send an test e-mail. I get no errors but the mail is not sent. Your help is appreciated.

== 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: "[email protected]" 
    #sendgrid_category :use_subject_lines 
    #sengrid_enable :ganalytics, :opentrack

    def test_notification 
      mail(:to => "[email protected]", :subject => "mail from heroku") 
      puts("Sent mail from notifier") 
   end 

   end 
======== 

I tried running the test_notification method from heroku console

>> Notifier.test_notification 

(This prints out some log info..)

#<Mail:Message:279922420, Multipart: false, Headers: <from.., To, Subject, etc). 

But send_grid doesn't report any mail sent out from my account. Not do I receive the e-mail.

I have also tried to send mail by an other means by calling test_notification from /home/index/controller which will be sent when visiting the home page of the app.

=== 
class HomeController < ApplicationController 
def index 
Notifier.test_notification() 
end

end

===

Stats don't report the mail as sent either. Any help is greatly appreciated.

Thanks! DS

2
  • I'm having the same issue. I think the integration is just broken. I've written support. We'll see how that goes. Commented Nov 5, 2011 at 6:30
  • were you guys able to figure this out? I am having the same issue. Commented Apr 6, 2012 at 1:23

2 Answers 2

7

try

Notifier.test_notification.deliver

you need to call the deliver method on your method to actually send the message.

http://guides.rubyonrails.org/action_mailer_basics.html

Sign up to request clarification or add additional context in comments.

Comments

0

Make sure you have a SendGrid add-on to your Heroku.To the code

user_name => ENV['SENDGRID_USERNAME'], 
:password => ENV['SENDGRID_PASSWORD'], 
:domain => ENV['SENDGRID_DOMAIN'], 

the details should be your sendgrid username,password and domain

1 Comment

is domain necessary? What does that do?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.