Rails ActionMailer 与 SendGrid

发布于 2024-09-28 01:47:27 字数 574 浏览 0 评论 0原文

我正在使用 SendGrid 在 Heroku 上发送电子邮件...

到目前为止的问题是,虽然它在 Heroku 上运行良好,但在我的本地主机上却失败了。

现在我在这里安装了 SendGrig,config/setup_mail.rb:

ActionMailer::Base.smtp_settings = {
  :address        => "smtp.sendgrid.net",
  :port           => "25",
  :authentication => :plain,
  :user_name      => ENV['SENDGRID_USERNAME'],
  :password       => ENV['SENDGRID_PASSWORD'],
  :domain         => ENV['SENDGRID_DOMAIN']
}

Heroku/SendGrid 的方式是什么,可以让我确保我的邮件程序在 DEV 中工作。这个 setup_mail.rb 文件是个好东西吗?它应该在 env 文件中吗?还有其他想法吗?

谢谢

I'm using SendGrid to send emails on Heroku...

The problem so far is while it works great on Heroku, on my local host it fails.

Right now I have SendGrig install here, config/setup_mail.rb:

ActionMailer::Base.smtp_settings = {
  :address        => "smtp.sendgrid.net",
  :port           => "25",
  :authentication => :plain,
  :user_name      => ENV['SENDGRID_USERNAME'],
  :password       => ENV['SENDGRID_PASSWORD'],
  :domain         => ENV['SENDGRID_DOMAIN']
}

What's a Heroku/SendGrid way to allow me to make sure my mailers work in DEV. Is this setup_mail.rb file a good thing? Should it be in the env file? Any other thoughts?

Thanks

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

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

发布评论

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

评论(2

苦妄 2024-10-05 01:47:27

使用 config/environments/[development.rb | Production.rb] 正如上面提到的 tfe 听起来像是要走的路。只需将 ActionMailer 配置放入这两个文件中,并更改它以适应开发|生产环境。

您还可以通过发出以下命令找到 Heroku 使用的 SendGrid 凭据:

heroku 配置 --long

这些凭据用于所有 SendGrid 身份验证(SMTP 身份验证、网站登录以查看统计信息等、API 访问)

-- Joe

SendGrid

Using config/environments/[development.rb | production.rb] as tfe mentioned above sounds like its the way to go. Just put the ActionMailer configuration in either of those files and change it to suit the development|production environment.

You can also find your SendGrid credentials used by Heroku by issuing the following command:

heroku config --long

These credentials are used for all SendGrid authentication (SMTP Auth, Website login to view stats, etc., API access)

-- Joe

SendGrid

开始看清了 2024-10-05 01:47:27

只需在开发环境中设置 SENDGRID_USERNAMESENDGRID_PASSWORDSENDGRID_DOMAIN 的环境变量即可。然后它就会起作用。

您可以从 Heroku 应用程序获取这些值的正确值。打开heroku控制台并获取ENV['SENDGRID_USERNAME']等值。

或者只是在本地使用一组不同的 SMTP 设置。或者用sendmail什么的。

Just set environment variables on your development environment for SENDGRID_USERNAME, SENDGRID_PASSWORD, and SENDGRID_DOMAIN. Then it will work.

You can get the correct values for these from your Heroku app. Open heroku console and get the values of ENV['SENDGRID_USERNAME'] and so on.

Or just use a different set of SMTP settings locally. Or use sendmail or something.

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