Ruby on rails Zoho的Rails ActionMailer配置

Ruby on rails Zoho的Rails ActionMailer配置,ruby-on-rails,ruby-on-rails-3,actionmailer,zoho,Ruby On Rails,Ruby On Rails 3,Actionmailer,Zoho,谁有幸配置ActionMailer通过Zoho帐户发送电子邮件 以下是我的设置: ActionMailer::Base.smtp_settings = { :address => "smtp.zoho.com", :port => 465, :domain => 'example.com', :user_name => 'steve@

谁有幸配置ActionMailer通过Zoho帐户发送电子邮件

以下是我的设置:

ActionMailer::Base.smtp_settings = {
    :address              => "smtp.zoho.com",
    :port                 => 465,
    :domain               => 'example.com',
    :user_name            => 'steve@example.com',
    :password             => 'n0tmypa$$w0rd',
    :authentication       => :login
}
>     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
但是,呼叫.传递超时:

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!'
用户可以使用端口465和SSL身份验证。我尝试过使用和不使用
:enable\u starttls\u auto=>true
,但它仍然超时

具体而言,将指定以下设置:

ActionMailer::Base.smtp_settings = {
    :address              => "smtp.zoho.com",
    :port                 => 465,
    :domain               => 'example.com',
    :user_name            => 'steve@example.com',
    :password             => 'n0tmypa$$w0rd',
    :authentication       => :login
}
>     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
有什么想法吗

p、 我已经将Outlook配置为使用发送电子邮件中的设置,并且可以正常工作。telnet到smtp.zoho.com 465也可以连接

# 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    
}

这对我很管用。您的设置可能很好一些本地网络会阻止这些类型的数据包。我必须通过我的3G网络进行测试。

我不确定Zoho是否已经更改了他们的安全设置,但我接受的答案不适用。但是,以下情况确实存在:

/config/initializers/action\u 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 } #ActionMailer电子邮件配置 ActionMailer::Base.delivery\u方法=:smtp ActionMailer::Base.smtp\u设置={ :address=>ENV['SMTP_address'], :port=>ENV['SMTP_port'], :domain=>ENV['SMTP_domain'], :user_name=>ENV['SMTP_USERNAME'], :password=>ENV['SMTP_password'], :身份验证=>:登录, :enable_starttls_auto=>true } 其中..
:地址
=
smtp.zoho.com

:端口
=
587

:域
是开发中的
本地主机
,并且是生产中的实时URL(例如
example.com

供参考:

假设您的域名是abc.com。
假设你的邮件上有一个不同域的“默认发件人”,例如

  default from: "\"Elephant\" <el@ephant.com>"
“大象”的默认值 除非您使用zoho帐户上的同一域更改“默认值”,否则此将不起作用。
所以

“大象”的默认值
将工作。

我使用Rails 4.2.3发送邮件,就像这样

# 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
当然,您也可以将其添加到
config/environments/production.rb

我还在
config/initializers/designe.rb
中设置电子邮件地址,以便发送密码重置指令

config.mailer_sender = 'noreply@truhawk.com'

参考资料


这些设置在生产中对我有效

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
  }

使用
smtp.zoho.eu
而不是
smtp.zoho.com
作为地址对我起到了作用。

你是在本地主机上尝试的吗???我是,当然smtp服务器是远程的(zoho.com)。这有关系吗?具有相同设置的电子邮件客户端(outlook)也位于同一本地主机上。不确定是否要使用outlook,Microsoft似乎不允许应用程序发送邮件,即使是电子邮件确认之类的必要内容。省略了传递方法:如果您收到EOFError消息,您可能试图使用的发件人地址不是Zoho中的实际帐户。查看此链接了解更多信息:您的端口应为465。将ssl和tls设置为true。