在Rails开发环境smtp cpanel上发送电子邮件ruby [英] Sending email ruby on rails dev environment smtp cpanel

查看:102
本文介绍了在Rails开发环境smtp cpanel上发送电子邮件ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在Rails上使用ruby发送电子邮件。使用gmail smtp时,它可以正常工作,但是当我尝试使用在cpanel中创建的电子邮件时,似乎现在无法发送任何电子邮件。有人知道如何配置吗?谢谢。

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.

这是我的mailer_setup.rb在Initializers文件夹下

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
}

这是environment.rb下的development.rb

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.

推荐答案

感谢其他答案,但我发现smtp端口应为 587 而不是 25 ,我发现它很奇怪,因为在cpanel配置中它说smtp端口位于端口25。

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.

这篇关于在Rails开发环境smtp cpanel上发送电子邮件ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆