【发布时间】:2017-06-13 09:18:54
【问题描述】:
我有一个通过 Mailgun 发送电子邮件的 Ruby Web 应用程序。
我的 Mailgun 帐户和 gem 已正确设置,我可以手动发送电子邮件(例如通过 curl)。
API 密钥和 API 基本 URL(https 沙箱域)存储在环境变量中。
当我尝试从应用程序发送电子邮件时:
def initialize(mailer: nil)
@mailer = mailer || Mailgun::Client.new(ENV['MAILGUN_API_KEY'])
end
然后:
def call(user)
mailer.send_message(ENV['MAILGUN_SANDBOX'], {from: '...',
to: user.email,
subject: '...',
text: "..."})
end
当我通过 localhost:xxxx 使用 Sinatra 运行应用程序时,我在 /.../... 301 Moved Permanently: ... nginx 处收到 Mailgun::CommunicationError 指向此行:
mailer.send_message(ENV['MAILGUN_SANDBOX'], ...
知道为什么会这样吗?我已经研究了这个问题几个小时,但找不到下一步该做什么的线索。
谢谢!
【问题讨论】:
标签: ruby nginx sinatra http-status-code-301 mailgun