DEVISE:Net :: SMTPSyntaxError:501 Sender语法错误

时间:2018-05-01 16:24:44

标签: ruby-on-rails devise

我在尝试使用Devise发送注册或密码重置电子邮件时收到错误Net::SMTPSyntaxError: 501 Sender syntax error

示例来自

'"Someone" <someone@mysite.com>'

邮件程序

class CustomDeviseMailer < Devise::Mailer
  include Roadie::Rails::Automatic

  layout 'email'

  default from: '"My Site" <me@mysite.com>'

  def confirmation_instructions(record, token, opts = {})
    check_white_label record, opts
    super
  end

  def reset_password_instructions(record, token, opts = {})
    check_white_label record, opts
    super
  end

  def unlock_instructions(record, token, opts = {})
    check_white_label record, opts
    super
  end

  def password_change(record, opts = {})
    check_white_label record, opts
    super
  end

  def check_white_label(record, opts)
    if white_label = record.player&.property&.management&.white_label_name
      opts[:from] = "#{white_label} <#{white_label}@mysite.com>"
      opts[:reply_to] = "#{white_label} <#{white_label}@mysite.com>"
    end
  end
end

2 个答案:

答案 0 :(得分:1)

您需要使用正确的发件人电子邮件格式: var parent = { childOne: { canHide : true, canStop : false, forms : [ {name: 'pathway 1', enabled: true}, {name: 'pathway 2', enabled: false}, {name: 'pathway 3', enabled: false} ] }, childTwo: { canHide : true, canStop : false, forms : [ {name: 'pathway 1', enabled: true}, {name: 'pathway 2', enabled: false}, {name: 'pathway 5', enabled: false}, {name: 'pathway 7', enabled: false} ] } }; var newParent = {}; // Here comes the funk(tion)! Object.keys(parent).map(function(child, index1) { var forms = parent[child]['forms']; Object.keys(forms).map(function(pathway, index2) { var pw_name = forms[pathway]["name"]; newParent[pw_name] = newParent[pw_name] || {}; newParent[pw_name][child] = { "enabled": forms[pathway]["enabled"] }; }); }); // Output console.log(newParent);

答案 1 :(得分:0)

我能够通过删除双引号来实现它。

LoadStringList()

输出

def check_white_label(record, opts)
  if white_label = record.player&.property&.management&.white_label_name&.delete('"')
    opts[:from] = "#{white_label} <#{white_label}@mysite.com>"
    opts[:reply_to] = "#{white_label} <#{white_label}@mysite.com>"
end