submail.cn rails 发送邮件

1.myubmail.com 注册 验证身份

2.godaddy购一个域名 我购的是qinfeng.in 先将dns设置里全部删除

3.在管理发信域名新增域名qineng.in


在域名管理dns填写
要验证通过才能发送邮件

代码设置

邮件一定要已经验证成功的

app/mailers/application_mailer.rb
class ApplicationMailer < ActionMailer::Base
  default from: 'admin@qinfeng.in'
  layout 'mailer'
end

开发环境

config/envirnments/development.rb
  config.action_mailer.default_url_options = {host: 'localhost:3000'}
  #config.action_mailer.delivery_method = :letter_opener

  config.action_mailer.delivery_method = :smtp

    ActionMailer::Base.smtp_settings = {
      address: "cloud.submail.cn",
      port: 25,
      domain: "qinfeng.in",                  #填写自己验证过的域名

      authentication: "plain",
      enable_starttls_auto: true,
      user_name: ENV["SUB_EMAIL_USER_NAME"],  #user_name 

      password: ENV["SUB_EMAIL_USER_KEY"]     #user_key

      }

生产环境

config/envirnments/production.rb
  config.action_mailer.delivery_method = :smtp

  ActionMailer::Base.smtp_settings = {
    address: "cloud.submail.cn",
    port: 25,
    domain: "qinfeng.in",
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: ENV["SUB_EMAIL_USER_NAME"],
    password: ENV["SUB_EMAIL_USER_KEY"]
    }

Comments

comments powered by Disqus