Sending email ruby on rails dev environment smtp cpanel

天涯浪子 提交于 2019-12-11 02:34:25

问题


I'm having trouble sending email using ruby on rails. When I'm using the gmail smtp, it's working fine but when I tried to use the email I created in cpanel, I can't seem to send any emails now. Does anyone know how to configure this? Thanks.

here's my mailer_setup.rb under initializers folder

ActionMailer::Base.delivery_method = :smtp # be sure to choose SMTP delivery
ActionMailer::Base.smtp_settings = {
  :address              => "mail.humouno.com",
  :port                 => 25,
  :domain               => "humouno.com",
  :user_name            => "info@humouno.com",
  :password             => "********",
  :authentication       => "login",
  :enable_starttls_auto => true
}

Here's the development.rb under environment.rb

Humouno::Application.configure do
  config.cache_classes = false
  config.eager_load = false

  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  config.action_mailer.raise_delivery_errors = false

  config.active_support.deprecation = :log

  config.active_record.migration_error = :page_load
  config.action_mailer.perform_deliveries = true

  config.assets.debug = true
end

I'm trying to send the email in my localhost.


回答1:


Thanks for the other answers but I found out that the smtp port should be 587 instead of 25, I find it weird since in the cpanel config, it says that the smtp port is at port 25.




回答2:


When I'm using the gmail smtp

why smtp_settings.address is not smtp.gmail.com? please check http://apidock.com/rails/ActionMailer/Base (Configuration options) and https://support.google.com/mail/answer/13287

and if using your smtp server is collect; I'd tail that some logs.



来源:https://stackoverflow.com/questions/22138699/sending-email-ruby-on-rails-dev-environment-smtp-cpanel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!