Completed 500 Internal Server Error in Rails 4 Devise Signup process - ruby-on-rails

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.

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.

Missing host to link to Rails heroku production

I have an app that I am trying to put onto production. When the user signs up they have an activation email that should be sent to their email accounts but I am getting stopped with this error:
ActionView::Template::Error(Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true)
The problem with this error is that I have everything set up correctly in my files. For example my production.rb file inside my environments folder looks like this:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => 'secret-everglades-54128.heroku.com'}
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
My enviorments.rb file looks like this:
# Load the Rails application.
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
config.action_mailer.default_url_options = { :host => 'secret-everglades-54128.heroku.com'}
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
This does not make any sense to me whatsoever, if anyone could shed some light on this problem I will be very great full.
The problem was that I had errors still concuring when I ran the command
git push heroku master
The problem was that I had my host set in the actually environment.rb file which wasn't needed so I removed that and once I did that I was able to get everything to work.

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'

emails not sending in 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.

Rails ActionMailer configuration for Zoho

Anyone have luck configuring ActionMailer to send email via a Zoho account?
These are my settings:
ActionMailer::Base.smtp_settings = {
:address => "smtp.zoho.com",
:port => 465,
:domain => 'example.com',
:user_name => 'steve#example.com',
:password => 'n0tmypa$$w0rd',
:authentication => :login
}
However, calling .deliver times out:
irb(main):001:0> AdminMailer.signup_notification('asfd').deliver
Timeout::Error: Timeout::Error
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:929:in `recv_response'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:552:in `block in do_start'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:939:in `critical'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:552:in `do_start'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:519:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'
The help docs say to use port 465 and SSL authentication. I've tried with and without :enable_starttls_auto => true but it still times out.
Specifically, the docs specify the following settings:
> Email Address: Username#yourdomain.com
> User Name format: Username#yourdomain.com
> Secure Connection (SSL) Yes
> Outgoing Mail Server Name: smtp.zoho.com
> Outgoing Port No.: 465
> Outgoing Mail Server requires authentication: Yes
Any ideas?
p.s. I've configured Outlook to use the settings in the help docs and outgoing email works fine. telnet to smtp.zoho.com 465 also connects.
# Action Mailer
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.zoho.com",
:port => 465,
:user_name => 'someone#somewhere.com',
:password => 'password',
:authentication => :login,
:ssl => true,
:tls => true,
:enable_starttls_auto => true
}
That worked for me. Your settings might be fine some local networks block these kinds of packets. I had to test it through my 3G network.
FYI:
Let's say your domain is abc.com.
Let's say you have 'default from' on your mailer with a different domain, e.g.
default from: "\"Elephant\" <el#ephant.com>"
This will not work unless you change your 'default from' using the same domain on your zoho account.
So,
default from: "\"Elephant\" <el#abc.com>"
will work.
I'm not sure if Zoho have changed their security settings, but #Tyrel Richey's accepted answer didn't work for me. However, the following does:
/config/initializers/action_mailer.rb..
# ActionMailer email configuration
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => ENV['SMTP_ADDRESS'],
:port => ENV['SMTP_PORT'],
:domain => ENV['SMTP_DOMAIN'],
:user_name => ENV['SMTP_USERNAME'],
:password => ENV['SMTP_PASSWORD'],
:authentication => :login,
:enable_starttls_auto => true
}
Where..
:address = smtp.zoho.com
:port = 587
:domain is localhost in development, and the live URL in production (e.g. example.com)
I have mail sending with Rails 4.2.3 like so...
# config/environments/development.rb
Rails.application.configure do
#...
config.action_mailer.default_url_options = { host: 'domain' }
config.action_mailer.smtp_settings = { address: 'smtp.zoho.com', port: 465, user_name: 'username#domain.com', password: 'mypassword', authentication: :login, ssl: true }
end
You can of course use this in production as well by adding this to config/environments/production.rb
I also set the email address in config/initializers/devise.rb so I can send password reset instruction.
config.mailer_sender = 'noreply#truhawk.com'
References
https://www.zoho.com/mail/help/zoho-smtp.html
http://guides.rubyonrails.org/action_mailer_basics.html
These settings worked for me in production.
Rails.application.routes.default_url_options[:host] = 'eyehawk.io'
config.action_mailer.default_url_options = { :host => 'eyehawk.io' }
config.action_mailer.perform_caching = false
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"
config.action_mailer.smtp_settings = {
:address => "smtp.zoho.com",
:port => 587,
:domain => "zoho.com",
:user_name => "admin#eyehawk.io",
:password => ENV['SMTP_PASSWORD'],
:authentication => :plain,
:enable_starttls_auto => true
}
Using smtp.zoho.eu instead of smtp.zoho.com as address did the trick for me.

Resources