I want to integrate SendGrid in my app and test how things work locally so I have my code send an email on a new user registration. I have my controller calling Notifier.welcome_email(user).deliver
When I tail the logs, the only related thing I see is:
Rendered notifier/welcome_email.html.erb (1.3ms)
But no email gets sent. In my environments/development.rb
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => '<user-name-is-here-actually.',
:password => '<and-the-password>',
:domain => 'domain.com',
:enable_starttls_auto => true
}
I still see nothing come through. Can anyone help me get this working locally?
The solution was just to make sure to call 'deliver' on the Notifier method.
Related
Im having issues with using sendgrid with my rails app on heroku. Can anyone tell me what I am doing wrong, or give me any pointers on how I could debug what is going wrong?
my config/environments/production file includes:
config.action_mailer.default_url_options = { :host => 'mydomain.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:user_name => 'apikey',
:password => Rails.application.credentials.sendgrid[:api_key],
:domain => 'mydomain.com',
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:enable_starttls_auto => true
}
Im getting a 500 error. In my development environment I used the letter opener gem and everything worked great. Thanks in advance.
I am trying to send mails with SendGrid from my Rails app (using Hartl's tutorial). It didn't work by simply using the addon at Heroku because it needed my credit card. Then I signed up on SendGrid and used my credentials as above, but still no mail. Here above is my production.rb file. Some help, please?
config.action_mailer.delivery_method = :smtp
host = '<https://nameless-sierra-13544>.herokuapp.com'
config.action_mailer.default_url_options = { host: host }
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['myusername'],
:password => ENV['mypass#'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
Merci,
In line with the comment above, I believe your values are just a little off. I also believe you need to have a from address set. This is a copy of what I use in production, with your values put in, and it works so hopefully this helps. I do believe that missing a valid from address and the characters in your domain value are why this is not working. Of course, also make sure you have the ENV variables set on heroku.
production.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host:'https://nameless-sierra-13544.herokuapp.com' }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
ActionMailer::Base.smtp_settings = {
:from => 'your_email_here#email.com',
:user_name => ENV['myusername'],
:password => ENV['mypass#'],
:domain => 'https://nameless-sierra-13544.herokuapp.com',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
I can't get my Rails app to send emails using Gmail. I can send emails on my local development environment but I can't send it from Heroku.
This is my config file.
application.rb
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:domain => 'gmail',
:port => 587,
:user_name => ENV['GMAIL_USERNAME'],
:password => ENV['GMAIL_PASSWORD'],
:authentication => 'login',
:enable_starttls_auto => true
}
I have tried authentication: 'login' and 'plain' but that didn't work either. I have tried putting this config both into application.rb and production.rb and that didn't work. I've tried domain: "my_my_name_on_heroku.com" but that didn't work either. I have also tried 'mail.google.com' but no luck either.
I have setup environment variables on Heroku with username and password properly (100% sure).
I have enabled less secure apps to get the application working at https://myaccount.google.com/lesssecureapps. No 2-factor authentication. I have enabled captcha to allow to login from different devices at http://www.google.com/accounts/DisplayUnlockCaptcha and still no emails are sent.
On Heroku logs I see that it says "Sending email to...", it renders the template fine, no errors whatsoever but I don't receive any emails. I've checked Spam folder as well but no emails there.
production.rb
config.action_mailer.default_url_options = { host: 'my_app.herokuapp.com' }
config.action_mailer.perform_caching = false
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default :charset => "utf-8"
What am I missing?
This is an active app I have had forever where the mail still works. Try changing the auth type to a symbol rather than a string. So :plain instead of 'plain'.
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:authentication => :plain,
:domain => 'blarg.com',
:user_name => 'info#blarge.com',
:password => 'password'
}
config.action_mailer.default_url_options = { :host => 'blarg.heroku.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
Net::SMTPAuthenticationError in Devise::ConfirmationsController#create
530-5.5.1 Authentication Required. Learn more at
I am using the gem 'devise'.
to send confirmation email with gmail account.
but, the error in title occur.
I searched many cases similar to my case and tried solutions in there, but those perfectly not worked, so I think my error has some different origin
( what I tried is : 1. less securing myaccount.google.com/u/1/security 2. http://www.google.com/accounts/DisplayUnlockCaptcha)
development.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:authentication => :plain,
:address => "smtp.gmail.com",
:port => 587,
:domain => "mail.google.com",
:user_name => ENV["******#gmail.com"],
:password => ENV["******"],
:enable_starttls_auto => true
}
config.action_mailer.default_url_options = {:host => 'localhost:3000'}
top most error line in error page
def check_response(res)
unless res.success?
raise res.exception_class, res.message
end
end
please help me... TT
the problem your gmail setting, you should remove the ENV as you put string directly to it (as my understanding this is your local development this will generate an error since you also put config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:authentication => :plain,
:address => "smtp.gmail.com",
:port => 587,
:domain => "mail.google.com",
:user_name => "******#gmail.com",
:password => "******",
:enable_starttls_auto => true
}
I'm using sendgrid on heroku to send email in production, but would like to send email locally on my mac.
I've configured my development.rb a million different ways and keep getting
"Net::SMTPFatalError: 550 Cannot receive from specified address : Unauthenticated senders not allowed"
Spefically, I tried
varying authentication b/w :plain and :login,
tried using my gmail account credentials,
tried using my google app account credentials.
Nothing seems to work, thoughts?
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
ActionMailer::Base.smtp_settings = {
:address => 'smtp.gmail.com',
:domain => 'somedomain.com',
:port => 587,
:user_name => 'username#somedomain.com',
:password => 'somepassword',
:authentication => :plain,
:enable_starttls_auto => true
}
I thought I had set the in the production settings (production.rb), it turns out I had set them in environment.rb. Removed it there and everything started working.
I had set the mail settings by accident in the Environment.rb so it was overriding anything I was doing at the production/development config level.
Could you try this?
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "email#gmail.com",
:password => "password",
:authentication => "plain",
:enable_starttls_auto => true
}