我正在使用 Rails 4 制作一个网络应用程序。
我设置了一个邮件程序来向新用户发送欢迎邮件。
我想将发件人姓名的外观从电子邮件地址更改为“欢迎使用 CF”。
在哪里设置发件人的姓名?
class WelcomeMail < ActionMailer::Base
self.delivery_method = :smtp
self.smtp_settings = {
user_name: ENV['GPROD_WELCOME'],
password: ENV['GPwPROD_WELCOME'],
port: 587,
domain: 'cr.com',
address: 'smtp.gmail.com',
authentication: 'plain',
enable_starttls_auto: true
}
def welcome_mail(user)
@user = user
mail(to: user.email, from: "angus@cr.com", subject: "Welcome to Cr, #{user.first_name}")
end
end
更改后,我希望 angus@cr.com 显示为 Welcome to CR。
最佳答案
更改邮件参数中的值:from: "Angus <angus@xyz.com>"
<> 之前的文本将显示为发件人名称。
关于ruby-on-rails - Rails - AdminMailer - 设置发件人姓名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32295415/