使用 Rails 3 在 Heroku 上运行 Gmail

发布于 2024-12-11 13:19:39 字数 927 浏览 1 评论 0原文

我正在尝试从 Heroku 发送电子邮件并运行。目前,我可以通过 http:// 上的“教程”从 Heroku 发送电子邮件/blog.heroku.com/archives/2009/11/9/tech_sending_email_with_gmail/,这样就可以了。

我当前的问题是,当我让它在 Heroku 上工作时,我无法让它在开发中工作。我已经使用environment.rb或development.rb中的设置启动并运行了它,但是在教程中的内容启动并且我删除了env/dev.rb中的设置之后,它不起作用。

在浏览器中我收到错误消息: 530-5.5.1 需要身份验证。了解更多信息(它在了解更多信息之后剪切)

在服务器控制台中,我收到错误消息: Net::SMTPAuthenticationError(530-5.5.1 需要身份验证。了解更多信息
):

我已经设置了 heroku config:add [email protected]heroku config:add GMAIL_SMTP_PASSWORD=yourpassword (带有我的信息;)),但它没有帮助。

有什么想法我做错了吗?

我可以在开发中采用旧的方式来完成并以某种方式跳过heroku脚本吗?

干杯卡尔

I am trying to send emails from Heroku up and running. At the moment I can send emails from Heroku via the "tutorial" at http://blog.heroku.com/archives/2009/11/9/tech_sending_email_with_gmail/, so that is fine.

My current problem is that when I got it to work at Heroku, I can't get it to work in development. I had that up and running with settings in either environment.rb or development.rb, but after the stuff in the tutorial kicked in and I removed the settings in env/dev.rb it doesn't work.

In the browser I get the error msg:
530-5.5.1 Authentication Required. Learn more at (it cuts after Learn more at)

In the server console I get the error msg:
Net::SMTPAuthenticationError (530-5.5.1 Authentication Required. Learn more at
):

I have set heroku config:add [email protected] and heroku config:add GMAIL_SMTP_PASSWORD=yourpassword (with my info ;)), but it doesn't help.

Any ideas what I am doing wrong?

Can I do it the old way in development and skip the heroku script in some way?

Cheers Carl

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

请远离我 2024-12-18 13:19:40

按照上述用户所说的 SMTP 设置即可。
除此之外,Gmail 还会阻止未经您验证的应用程序对您的帐户进行未经身份验证的登录。
因此,请转到您的 Gmail 客户端并登录。

如果不起作用,请转至解锁验证码

Just do as the above user has said about the SMTP settings.
In addition to that, Gmail blocks unidentified logins from a application to your account without you verifying it.
So go to your Gmail client and log in there.

If that doesn't work go to unlock captcha

末蓝 2024-12-18 13:19:40

我个人曾遇到过使用 Gmail 发送邮件时出现的错误,需要解决解锁验证码才能允许发送。 Gmail 有时对安全性很挑剔,而且文档也不是很明显。

完整消息应为:

530-5.5.1 Authentication Required. Learn more at https://support.google.com/mail/bin/answer.py?hl=en&answer=14257

请查看该链接 并按照那里的说明进行操作。

您可能需要登录 Gmail 网络应用,或者(我必须这样做)解决解锁验证码问题。或者可能是您的应用程序或环境中的某些内容,但遵循 Google 指示值得一试。

I have personally encountered that error sending with Gmail and needed to solve an unlock CAPTCHA to allow the sending. Gmail can be picky with security sometimes, and the documentation is not very apparent.

The full message should read:

530-5.5.1 Authentication Required. Learn more at https://support.google.com/mail/bin/answer.py?hl=en&answer=14257

so check out that link and follow the directions there.

You might need to sign into the Gmail webapp or (what I had to do), solve the unlock CAPTCHA. Or perhaps it is something in your app or environment, but following the Google directions is worth a shot.

熊抱啵儿 2024-12-18 13:19:40

请在 config/environments/development.rb 中添加以下代码

config.action_mailer.raise_delivery_errors = false
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true

,并确保已在 config/initializers/smtp_gmail.rb 中添加以下代码

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :user_name            => "[email protected]",
  :password             => "password",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

Please add the following code in config/environments/development.rb

config.action_mailer.raise_delivery_errors = false
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true

and also make sure you have added the following in config/initializers/smtp_gmail.rb

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :user_name            => "[email protected]",
  :password             => "password",
  :authentication       => "plain",
  :enable_starttls_auto => true
}
非要怀念 2024-12-18 13:19:40

您是否在本地计算机上导出了这些环境变量?您说您要将 GMAIL_SMTP... 添加到 Heroko 配置中,但是您是:

$ export [电子邮件受保护]
$ export GMAIL_SMTP_PASSWORD=yourpassword

我遇到了你的问题,因为我也有电子邮件在开发中工作,并且想知道 2009 年关于如何获取 smtp & 的帖子是否有效。 gmail 在 Heroku 上工作仍然是必要的。显然是这样。

Did you export those environment variables on your local machine? You say you're adding the GMAIL_SMTP... to heroko config, but are you:

$ export [email protected]
$ export GMAIL_SMTP_PASSWORD=yourpassword

I ran into your question because I also have email working in dev, and wondered if the 2009 post about how to get smtp & gmail to work on heroku is still necessary. Apparently so.

沉睡月亮 2024-12-18 13:19:40

我在 heroku 应用程序上通过 Gmail 发送邮件。这是我的配置,如果有帮助的话。我没有使用任何第三方插件,只是使用 Rails 3。

config/initializers/setup_mail.rb

ActionMailer::Base.smtp_settings = {
  :address  => "smtp.gmail.com",
  :port  => 587,
  :user_name  => "[email protected]",
  :password  => "foobar",
  :authentication  => :plain,
  :enable_starttls_auto => true
}

中 在 config/environments/Production.rb

end<对于 config 块的 /code> 语句,我添加了

ActionMailer::Base.smtp_settings[:enable_starttls_auto] = false

I have mail being sent via Gmail on a heroku app. Here is my config if it helps. I am not using any third party plugins, just Rails 3.

In config/initializers/setup_mail.rb

ActionMailer::Base.smtp_settings = {
  :address  => "smtp.gmail.com",
  :port  => 587,
  :user_name  => "[email protected]",
  :password  => "foobar",
  :authentication  => :plain,
  :enable_starttls_auto => true
}

In config/environments/production.rb

After the end statement for the config block, I have added

ActionMailer::Base.smtp_settings[:enable_starttls_auto] = false

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文