【问题标题】:Rails 3.2: Devise: Email NameRails 3.2:设计:电子邮件名称
【发布时间】:2013-08-19 00:30:02
【问题描述】:

我有一个使用 Devise 进行身份验证的 Rails 3.2 应用程序。

我希望注册确认电子邮件将“Foo Signups”作为发件人:电子邮件名称和“signups@foo.com”作为电子邮件地址。现在,我只有“signups@foo.com”作为发件人:电子邮件地址。

我的配置如下所示:

# in the file config/initializers/devise.rb
Devise.setup do |config|
  config.mailer_sender="signups@foo.com"

# etc...

和

# in the file config/environments/development.rb
config.action_mailer.smtp_settings = {
  address: "smtp.gmail.com",
  port: 587,
  authentication: "plain",
  enable_starttls_auto: true,
  user_name: ENV["GMAIL_ADDRESS"],
  password: ENV["GMAIL_PASSWORD"]
}

其中 GMAIL_ADDRESS 和 GMAIL_PASSWORD 是我的 Gmail 用户名和密码作为环境变量,与 signups@foo.com 不同。

如何配置 SMTP 或 Devise 以将“Foo Signups”作为电子邮件名称,将“signups@foo.com”作为电子邮件地址?

【问题讨论】:

    标签: email devise ruby-on-rails-3.2


    【解决方案1】:

    使用 ActionMailer,您可以设置类似于"#{@user.name} <#{@user.email}>" 的发件人电子邮件地址

    我没有在 Devise 中尝试过,但我认为相同的思考过程适用于配置,因为我确信它只是将信息发送到 ActionMailer:

    Devise.setup do |config|
      config.mailer_sender= "Foo Signups <signups@foo.com>"
      #...
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-10
      • 2016-05-30
      • 1970-01-01
      • 2015-04-07
      • 1970-01-01
      • 1970-01-01
      • 2014-07-18
      相关资源
      最近更新 更多