sendcloud 给的官方例子是在下面。rails(4.1)下是通过 actionmailer 来发送邮件的,那如何在 rails 当中来查看 reponse 呢?
#!/usr/bin/env ruby
require 'rubygems'
require 'rest_client'
def send_attachment_mail
response = RestClient.post "https://sendcloud.sohu.com/webapi/mail.send.xml",
:api_user => "[email protected]",
:api_key => "password",
:from => "[email protected]",
:fromname => "from名称",
:to => "[email protected];[email protected]",
:subject => "ruby 调用WebAPI测试主题",
:html => '欢迎使用<a href="https://sendcloud.sohu.com">SendCloud</a>',
:attachment1 => File.new("/path/to/doc/操作指南v2.6.pdf", 'rb'),
:attachment2 => File.new("/path/to/doc/WEB API文档.pdf", 'rb')
return response
end
response = send_attachment_mail
puts response.code
puts response.to_str
UPDATE:大家在使用 sendcloud 的时候还是有很多问题啊,我把我的 demo 放上来做参考吧:https://github.com/luckyyang/sendcloud-demo
有需求的话我可以考虑录期视频。