【问题标题】:Rails - Sending emails with name not workingRails - 发送带有名称的电子邮件不起作用
【发布时间】:2015-02-13 13:18:42
【问题描述】:

我正在尝试使用发件人地址中的用户名发送邮件。类似于"John Doe <john@doe.com>"。我经历了很多 SO 解决方案,但仍然无法使其正常工作。

这是邮件:

def trigger_email(send_mail, contact, user)
    @mailer = send_mail
    @email = contact.email
    @user = User.find(user)
    mail(to: @email, subject: @mailer.subject, from: "\"#{@user.name}\" <@user.email>")
end

我已经尝试了上述的很多变体,但没有任何效果。希望能解决这个问题。

【问题讨论】:

标签: ruby-on-rails


【解决方案1】:

mail() 行中的 from: 值似乎是错误的。试试:

mail(to: @email, subject: @mailer.subject, from: "#{@user.name} <#{@user.email}>")

如果这不起作用,请与您的电子邮件提供商联系,也许他们正在改变它?

【讨论】:

    猜你喜欢
    • 2017-09-20
    • 2015-06-06
    • 2016-07-28
    • 2014-01-28
    • 1970-01-01
    • 1970-01-01
    • 2012-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多