emails not sending in ruby on rails - ruby-on-rails

I did the same thing as in this link http://www.tutorialspoint.com/ruby-on-rails/rails-send-email.htm. it is showing mail sent in output window of net-beans with the message but it is not actually sending the mail. can anyone tell me what could be the problem?
i have searched a lot but m not getting any solution.
I am using net-beans with ruby 1.5.1, rails 2.3.8. I have searched but I only got the solution to update j-ruby. If it is so then please tell me how to use updated version of j-ruby in net-beans.
the following code is in environment.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail',
:user_name => "id#gmail.com",
:password => "",
:authentication => 'plain',
:enable_starttls_auto => true }
thanks

can you please check that whether you have do this or not
config.action_mailer.perform_deliveries = true
Please let me know
Thanks

Please check with your network provider if your smtp port is open. or check using telnet commands. If you work under a company network which has restrictions on sending mails, you should explicitly ask for permission and get the port opened.
The mail sent message will be shown in output even if it isnt actually sent. So pls make sure you have the following changes made to know the errors in your config/environments/development.rb or production.rb depending on in which mode you are running your server
config.action_mailer.raise_delivery_errors = true

Visit the following link for more detail about Action Mailer.
Update your mailer settings:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail',
:user_name => "id#gmail.com",
:password => "******",
:authentication => 'plain',
:enable_starttls_auto => true }
Where ****** is your email password.

Related

Not receiving mail from Heroku Sendgrid addon

So i've look at a few similar posts here on SO, but for some reason my sendgrid config in heroku is not working.
Here's my config / production.rb
config.action_mailer.default_url_options = { :host => 'poliking.herokuapp.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
ActionMailer::Base.smtp_settings = {
:from => 'wesleycreations#gmail.com',
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'poliking.herokuapp.com',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
Everything worked perfectly fine in development. I tried all the obvious, YES variables are properly set and YES I enabled my gmail to allow mail from less secure apps.
added gem sendgrid gem to my gem file
gemfile.rb
gem 'sendgrid-ruby'
Again, everything working fine in development and I am receiving email to same email address. But this isn't working in production. Any thoughts?
Here's the log:
...MailForm::Notifier#contact: processed outbound mail in 3.3ms...
Delivered mail 5f246d3cbf2d9_42af68b690f1c810d6#dad81cb4-1ce9-440e-b8...
With config.action_mailer.raise_delivery_errors = false, the errors raised during e-mail delivery will be suppressed.
Therefore, change that option to true so that you can diagnose the problem.

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.

rails emails from heroku

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

Rails 3 action mailer production OpenSSL::SSL::SSLError: hostname does not match the server certificate

I am facing problem with Open SSL certificate error while sending email in production server. Everything is working fine in development mode. Below is my configuration code in production mode.
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => "plain",
:enable_starttls_auto => true,
:user_name => 'xxxxxxx',
:password => 'xxxxx',
:openssl_verify_mode => 'none'
}
I have already looked at the solution in previous post But, that does not solve my problem.
Could anyone kindly help with this one?
Try adding the domain name in smtp_setings
:domain => 'www.your-domain-name.com'

Completed 500 Internal Server Error in Rails 4 Devise Signup process

When I go to signup a new user on the site I fill in the form, click submit, and it sits there for a few seconds, then dispays 'We're sorry, but something went wrong.'
The Log is below...
https://gist.github.com/th3cuda/225f1352a7cfeee3f8f8
This is deployed on digitalocean.
production.rb
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
config.action_mailer.default_url_options = { :host => 'MY_HOST' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'smtp.MY_DOMAIN.com',
:port => 465,
:domain => 'MY_DOMAIN',
:user_name => 'MY_EMAIL',
:password => 'PASSWORD',
:authentication => 'plain',
:enable_starttls_auto => true
}
end
Since it's taking a while, it could be looking for sendmail (it uses /usr/sbin/sendmail by default) to send the email.
I would make sure that it's in place, that it can be used by the app, and that the config/(Dev, Prod, etc.) allows it to deliver email.
Is any of that helpful? Let me know what you find so I can give a better answer.
Sorry to add another answer, but formatting here is important.
config.action_mailer.default_url_options = { :host => 'MY_HOST' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'smtpout.secureserver.net',
:port => 80,
:domain => 'www.example.com',
:user_name => 'johndoe#example.com',
:password => 'yourpassword',
:authentication => 'plain'
}
end
Notice I removed the starttls option, and set port to 80. Obviously, replace with your real values. If you're using constants, please avoid using those until this gets resolved.

Resources