简体   繁体   English

ActionMailer Rails:无法发送电子邮件

[英]ActionMailer Rails : Not able to send emails

I have the following code in my environment/development.rb 我在environment / development.rb中有以下代码

 config.action_mailer.raise_delivery_errors = true;
 config.action_mailer.delivery_method = :smtp;
 config.action_mailer.smtp_settings = {
   :address => "smtp.gmail.com",
   :port => 587,
   :user_name => "my_id@gmail.com",
   :password => "secret",
   :authentication => :plain,
   :enable_starttls_auto => true,
   :domain => "localhost",
 }

An email is being generated by the call to the mailer model from one of my controllers. 通过从我的一个控制器调用邮件程序模型生成一封电子邮件。 However, i am not able to send or receive any emails on gmail. 但是,我无法在Gmail上发送或接收任何电子邮件。

I am on ruby 1.8.7, rails 2.3.5. 我在ruby 1.8.7,rails 2.3.5。 There are no exceptions, just that no emails are being exchanged between the actual mail servers. 没有例外,只是在实际的邮件服务器之间没有交换电子邮件。

Being quite new to mailer, sorry for any rookie questions. 对于邮件来说还是个新手,对于任何新手问题都很抱歉。

A similar query: Actionmailer not working in rails 2.3 一个类似的查询: Actionmailer不在rails 2.3中工作

Thanks 谢谢

Above your code you you need to put those lines mandatory for the authentication: 在代码上方,您需要将这些行强制用于身份验证:

require 'tlsmail'
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)

You need also the tlsmail gem. 你还需要tlsmail gem。

If it doesn't work you can try removing the domain key from you settings. 如果它不起作用,您可以尝试从您的设置中删除域密钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM