rails emails from heroku - ruby-on-rails

I am trying to send emails through my godaddy shared hosting account.
I have setup the email: hello#example.com
In rails i have the following in both:
app/config/environments/development
app/config/environments/production
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'mail.thaismilejersey.com',
:port => '25',
:authentication => :plain,
:user_name => ENV['EMAIL_ADDRESS'],
:password => ENV['EMAIL_PASSWORD'],
:domain => 'thaismilejersey.com',
:enable_starttls_auto => true,
:openssl_verify_mode => 'none'
}
When I run this in both development and production locally, the emails are sent and I receive them fine.
When I deploy to heroku, everything seems to work, but the emails never actually arrive in my inbox.
ps: I have tried specifying the username and password directly rather than variables but it makes no difference.
Does anyone have any experience doing this or could help me out at all?
Thanks

Related

Why can't I see any emails in my inbox sent from my Heroku Rails app using SendGrid SMTP Relay in development mode?

I'm trying to switch over to SendGrid from Mandrill in my Rails 4.2 app through SendGrid's SMTP Relay. I have set the 'To Email' to be my personal email address so that I can view the emails that have been sent, however none of the emails actually appear in my inbox despite the rails console claiming to have processed and sent the email.
I am fairly certain all my mailers have the appropriate smtp settings as I have mostly followed the instructions provided on the SendGrid website: https://sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html
I have also tested my connectivity to SendGrid's SMTP Relay through telnet and the connection is succesful.
My SendGrid dashboard indicated that 0 emails have been sent. None of my emails appear under the Suppressions tab either so it's not like they have bounced or have been blocked.
This is in my config/environment.rb:
ActionMailer::Base.smtp_settings = {
:user_name => 'apikey',
:password => ENV['SENDGRID_API_KEY'],
:domain => 'heroku.com',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
This is in my config/environments/development.rb:
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'smtp.sendgrid.net' }
This is the line in my controller that calls my ApplicationMailer:
ApplicationMailer.send_email(user, 'mypersonalemail#email.com', 'Test Subject').deliver
And this is what gets printed in the console when the mailer method is executed:
ApplicationMailer#send_email: processed outbound mail in 789.9ms
Sent mail to mypersonalemail#email.com (103.4ms)
But I still don't get any emails in my inbox or spam folder. Does anyone know how I can solve this? Thanks in advance.
Your domain and host options are wrong. Use localhost:3000 (unless you're using docker or something at which point replace localhost:3000 with 0.0.0.0:8000)
#/environments/development.rb
#Mailer Options
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'localhost:3000',
:enable_starttls_auto => true
}
config.action_mailer.default_url_options = { host: 'http://localhost:3000' }
config.action_mailer.asset_host = 'http://localhost:3000'
Make sure to add the sendgrid credentials to your local machine as environment vars. To get them, go to your heroku app and click on settings, then "reveal config vars". Then add those sendgrid credentials to your local machine as env. vars and you're done.

Sending Mail in Rails App Heroku

I have Users that are able to invite others by email to a project they are working on but I keep getting the following error-
Net::SMTPAuthenticationError
Here is how I have mail settings configured for my production environment
config.action_mailer.default_url_options = { :host => 'myapp.herokuapp.com' }
#Sending email on the production side
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => "587",
:domain => "gmail.com",
:authentication => :plain,
:user_name => "example#gmail.com",
:password => "password"
}
It works in my local environment using sqlite3 as I expect but when I push to heroku it throws the above error after running heroku logs. I believe my config settings to be correct and obviously heroku uses postgresql, so what am I missing here?
Thanks for you r attention.
I found the reason here How to send confirmation e-mails using gmail smtp service for registration using devise under development mode locally?
Google had detected some "suspicious" activity on the newly created account and was blocking me from sending emails. After verifying the account I was able to send emails with the above config and switching :domain => "heroku.com"

Devise confirmation emails being sent to wrong Heroku application

I am running two Rails 3.1.0 apps on Heroku. One of these apps is just for staging purposes. I am using Devise for authentication and sendgrid to handle email.
When a user registers on the main app, the confirmation email seems to be sent fine. However, when the user clicks the confirmation link in the email, they are sent to the staging app instead. The link in the email is confirmation_url, which does not seem to be hard-coded to anything in my app.
Any ideas on why this might be occurring or suggestions on how to go about debugging?
You've most likely set this in your config/environments/production.rb
# Email settings
config.action_mailer.default_url_options = { :host => "www.your-staging-server-url.com" }
config.action_mailer.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com'
}

Will switching on two-factor authentication stop my Heroku app accessing the Gmail server?

In the past, I've sent email from Heroku apps using the Gmail server, like this:
config.action_mailer.deconfig.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'derp'
:user_name => 'derp.bot',
:password => 'derp42069',
:authentication => 'plain',
:enable_starttls_auto => true }
Since then I've enabled two-factor authentication for most of my domains. Before I do the same for my latest domain, will in wreck havoc with Rails code like you see above?
If the change does break your code, you could fix work around it by using an application-specific password.

Delivery issues with Rails + Gmail SMTP in Dreamhost

I just released a Rails app in Dreamhost and I'm using Google Apps for my domain to handle Emai. I created the admin#domain.com account to serve as the sender authentication.
I installed smtp-tls plugin and my smtp conf is:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "www.domain.com",
:authentication => :plain,
:user_name => "admin#domain.com",
:password => 'secret'
}
The problem: Emails sometimes arrives, and sometimes don't. The recipient addresses are not exclusively Yahoo or GMail accounts, so I think it's not a spam issue. Any ideas? Thanks!
If you want better tracking of whether or not your emails are getting where you're trying to send them, checkout PostageApp:
http://postageapp.com/

Resources