Gem sendcloud_rails

towonzhou · 2016年07月27日 · 最后由 towonzhou 回复于 2016年10月16日 · 3173 次阅读

一直用 mailgun 来发邮件,发现对 qq 邮箱的支持不太好,于是换成 sendcloud, 可惜 sendcloud 没有现成的 rails gem,照着 mailgun_rails 写了个 sendcloud_rails

github 地址 (https://github.com/towonzhou/sendcloud_rails)

Installing

In your Gemfile

gem 'sendcloud_rails'

Usage

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'

感谢大拿分享!

send_cloud 客服不错

点了一下关闭话题

如果不用 Gem 的话 直接 SMTP 方式就可以了嘛 而且 SendCloud 发送 Gmail 之类个别海外邮件送达率有问题,需要结合一下 Mailgun 之类的服务

#4 楼 @jasl 理论上干什么都可以不用 gem. 恩,海外邮箱还是 mailgun 好

#5 楼 @towonzhou 用 SMTP 有个好处,如果你需要做邮件发送的路由的时候(就是 mailer 内做白名单,根据不同邮箱域名使用不同的邮件发送服务来发送),只需要在 mailer interceptor 修改 SMTP 的相关字段即可(类似字典),动态设置 deliver_method 好像不太容易达成这点,尤其是使用独立 IP 的话会建议设置 DKIM 签名,这个使用不同家服务证书会不同。

不过 SendCloud 现在有海外通道了,完全只用 SendCloud 也不是没问题,之前有人提过在网页后台设置域名白名单限制在十条,这个是不太够的,最后还是要扔到程序里来解决。

7 楼 已删除

#6 楼 @jasl

mail(:from => '[email protected]',           
       :to => '[email protected]', 
       :subject => 'Subject',
       :delivery_method => some_condition ? :foo : :bar)

这样不就可以动态的设置 deliver_method 吗?

我是来赞 sendcloud 客服的。我的密码找回邮件被人恶意发送并举报,sendcloud 打电话来说了被举报的情况,我即使处理后几分钟就重新开通了,虽然我是免费用户!

#9 楼 @towonzhou 我来解释下我这边的场景吧:

  • 我们分成触发式邮件和 EDM 两种,触发式邮件就是找回密码、激活信息、私信之类,EDM 周报一些推广邮件,SendCloud 要求 API_USER 必须是其中之一,所以要根据发送邮件的性质使用不同的 API_USER 的账号
  • 因为量大,我们有 4 个 IP,在发送的时候我们尽量均匀的使用这些 IP
  • 使用 Mailgun 发送 Gmail 等个别邮箱(后来改用海外通道了)
  • 要为使用 SendCloud 发送的邮件添加 DKIM 信息

#11 楼 @jasl mail(:from => '[email protected]',
:to => '[email protected]', :subject => 'Subject', :delivery_method => some_condition ? :foo : :bar, :api_user => get_api_user )

然后在我的这个 gem 里面修改一下 build_basic_sendcloud_message_for 方法,以传进来的 api_user 为主就可以达到你说的修改 api_user 了

#13 楼 @jasl 问:如何升级为高级会员?

#15 楼 @towonzhou 高级会员是 ID 号在 1024 之内的,要不就是多少之前的。。。忘了

正在找这个,多谢!

需要 登录 后方可回复, 如果你还没有账号请 注册新账号