使用rails在“来自”电子邮件字段中动态显示配置文件用户名

时间:2016-04-26 13:12:20

标签: ruby-on-rails email email-integration

我们目前正在构建一个基于网络的应用程序,允许用户注册并创建个人资料。他们可以使用动作制作者从平台发送电子邮件,但不是显示默认的“无回复”作为来自我们需要显示发件人姓名的字段。有谁知道这是否可能?

2 个答案:

答案 0 :(得分:0)

使用“发件人”标题,如:Action mailer options

邮件的发件人字段是显示的名称,表示发送的公司或个人。回复标题是它发送的邮件。

如果没有看到您正在使用的任何代码,我无法帮助您。

示例代码:

class UserMailer < ApplicationMailer
default from: 'notifications@example.com'
default reply-to: 'notifications@example.com'

def welcome_email(user)
@user = user
@url  = 'http://example.com/login'
mail(to: @user.email,
     from: 'Name of sending user here <notifications@example.com>',
     subject: 'Welcome to My Awesome Site',
     template_path: 'notifications',
     template_name: 'another')
end
end

答案 1 :(得分:0)

SMTP只是一种基于文本的协议,没有真正的验证。您可以发送包含任何from字段的电子邮件。