ROR发送电子邮件heroku,gmail

编程入门 行业动态 更新时间:2024-10-27 08:37:03
本文介绍了ROR发送电子邮件heroku,gmail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我设法在我的本地机器上配置ActionMailer以通过Gmail发送电子邮件。 (它需要gemfile中的tlsmail) $ $ p $ $ $ c $ ### config / environment.rb 需要'tlsmail' Ideas:Application.configure do config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method =:smtp config.action_mailer.smtp_settings = { :address => 'smtp.gmail',:port => '587',:domain => 'xxxx@gmail',:user_name => 'xxxx@gmail',:password => 'xxxxxxx',:authentication => :plain } end

这可以在我的本地机器上运行(电子邮件被发送),但通常hreoku有这个问题(Errno :: ECONNREFUSED(Connection refused - connect(2)))。我搜索了一下,他们对gmail有一个特别的解决方案:

blog.heroku/archives/2009/11/9/tech_sending_email_with_gmail/

他们在说我需要一个额外的SMTP TLS库。如上所述,我添加了一个解决问题的gem,但只在我的本地机器上解决。好吧,我尝试了他们的解决方案,并在Heroku上运行......但停止了在我的本地工作。 (它没有给出错误,它只是表示电子邮件已发送,但它从来没有。)

环境变量设置正确。

你有什么想法让至少有一种方法可以在我的本地计算机和heroku上运行吗?

Bye 您需要在正确的环境中设置它。您需要在您的gemfile中使用group

完成此操作

group:development do gem'< development gem这里>' group:生产do gem'<这里是生产宝石>'

不要忘记重新包装。然后将与每个环境相关的配置移动到config / environments / production.rb或config / environments.development.rb中。

I managed to configure ActionMailer on my local machine to send emails via Gmail. (it required tlsmail in gemfile)

### config/environment.rb require 'tlsmail' Ideas::Application.configure do config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => 'smtp.gmail', :port => '587', :domain => 'xxxx@gmail', :user_name => 'xxxx@gmail', :password => 'xxxxxxx', :authentication => :plain } end

This worked on my local machine (the emails were sent) but as usually hreoku had some problems with this (Errno::ECONNREFUSED (Connection refused - connect(2))). I googled that they have a particular solution for gmail:

blog.heroku/archives/2009/11/9/tech_sending_email_with_gmail/

They are saying I need an additional SMTP TLS library. As mentioned above I added a gem that resolved the issue but only on my local machine. Well ok, I tried their solution and it worked... on heroku, but stopped working on my local. (it doesn't give an error, it just says the email was sent, but it never is.)

Environmental variables are set properly.

Do you have any ideas how to make at least one of this methods work both on my local machine and heroku?

Bye

解决方案

You need to set it up in the correct environment. You'll need to do this in your gemfile with groups

group :development do gem '<development gem here>' group :production do gem '<production gem here>'

Don't forget to rebundle. Then move the config relevant to each environment into either config/environments/production.rb or config/environments.development.rb

更多推荐

ROR发送电子邮件heroku,gmail

本文发布于:2023-10-07 10:26:22,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送电子邮件   ROR   gmail   heroku

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!