【问题标题】:RestClient::ResourceNotFound (404 Resource Not Found):RestClient::ResourceNotFound(404 资源未找到):
【发布时间】:2013-07-06 12:56:46
【问题描述】:

我正在尝试使用 RestClient 和 mailgun 发送邮件。

我在我的 Rails 应用程序中安装了 gem,并在 config/application.rb 中定义了“require 'rest_client'”。

然后为了发送邮件,我在消息控制器中写了这个:

 RestClient.post "https://api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0" "@api.mailgun.net/v2/samples.mailgun.org/messages",  :from => "Excited User <me@samples.mailgun.org>",  :to => "sergeyo@profista.com, serobnic@mail.ru",  :subject => "Hello",  :text => "Testing some Mailgun awesomness!"

我已经使用 mailgun 创建了帐户,并使用了上面我帐户中提到的密钥和 url。

当我运行代码时,它给出了错误:

 RestClient::ResourceNotFound (404 Resource Not Found):

任何人都可以帮助我这里出了什么问题吗?

【问题讨论】:

    标签: ruby-on-rails-3.2 rest-client mailgun


    【解决方案1】:

    您必须将这部分“samples.mailgun.org”更改为您的帐户信息中列出的域,有 mailgun 子域和自定义域。

    假设您有一个名为 sandbox0000.mailgun.org 的子域

    #i prefer to join the strings
    
    url = "https://api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0@api.mailgun.net/v2/sandbox0000.mailgun.org/messages"
    
    RestClient.post url,  :from => "Excited User <me@samples.mailgun.org>",  :to =>    "sergeyo@profista.com, serobnic@mail.ru",  :subject => "Hello",  :text => "Testing some Mailgun awesomness!"
    

    您的 api 密钥是 mailgun 的密码,您不应将其公开。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-13
      • 1970-01-01
      • 1970-01-01
      • 2017-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多