一直用 mailgun 来发邮件,发现对 qq 邮箱的支持不太好,于是换成 sendcloud, 可惜 sendcloud 没有现成的 rails gem,照着 mailgun_rails 写了个 sendcloud_rails
github 地址 (https://github.com/towonzhou/sendcloud_rails)
In your Gemfile
gem 'sendcloud_rails'
To configure your sendcloud credentials place the following code in the corresponding environment file (development.rb
, production.rb
...)
config.action_mailer.delivery_method = :sendcloud
config.action_mailer.sendcloud_settings = {
api_user: '<apiUser>',
api_key: '<apiKey>',
api_url: 'http://api.sendcloud.net/apiv2/mail/send'
}
Now you can send emails using plain Action Mailer:
email = mail from: '[email protected]', to: '[email protected]', subject: 'this is an email'