0
我想使用Mailjet來發送訂單確認電子郵件。在rails中使用mailjet
首先,我安裝了寶石和配置爲Mailjet guide
gem 'mailjet'
初始化/ mailjet.rb
Mailjet.configure do |config|
config.api_key = '<my_api_key>'
config.secret_key = '<my_secret_key>'
config.default_from = '<my_email>'
end
的config/application.rb中
config.action_mailer.delivery_method = :mailjet_api
這是行動在我的控制器中
def send_email_reserved
email = { :from_email => "<my_from_email>",
:from_name => "Dona Sky",
:subject => "Hello",
:text_part => "Hi",
:recipients => [{:email => "<my_to_email>"}] }
test = Mailjet::Send.create(email)
p test.attributes['Sent']
end
當我打電話的動作,這表明錯誤
NoMethodError: undefined method `[]' for #<Set: {#<MIME::Type: application/json>}>
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/request.rb:307:in `type_for_extension'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/request.rb:312:in `type_for_extension'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/request.rb:286:in `block (2 levels) in stringify_headers'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/request.rb:286:in `map'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/request.rb:286:in `block in stringify_headers'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/request.rb:272:in `each'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/request.rb:272:in `inject'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/request.rb:272:in `stringify_headers'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/request.rb:92:in `make_headers'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/request.rb:58:in `initialize'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `new'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/rest-client-1.6.7/lib/restclient/resource.rb:67:in `post'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/mailjet-1.3.8/lib/mailjet/connection.rb:67:in `handle_api_call'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/mailjet-1.3.8/lib/mailjet/connection.rb:47:in `post'
from /Users/Dona/.rvm/gems/ruby-2.2.2/gems/mailjet-1.3.8/lib/mailjet/resource.rb:215:in `save'
我遇到了錯誤: 找不到寶石的休息時間,客戶〜> 1.6.9「任何在你的Gemfile或上市本機上的寶石的來源。 –
嘗試:gem install rest-client -v 1.6.9運行之前 –