Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails - AdminMailer - setting sender name

I am using Rails 4 to make a web app.

I have a mailer set up to send a welcome mailer to new users.

I want to change the appearance of the sender name from the email address to "Welcome to CF".

Where to I set the name of the sender?

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: "[email protected]", subject: "Welcome to Cr, #{user.first_name}")
end


end

When it's changed, I want [email protected] to appear as Welcome to CR.

like image 292
Mel Avatar asked Oct 26 '25 08:10

Mel


1 Answers

Change the value of from within your mail params:

from: "Angus <[email protected]>"

The text before the <> will be displayed as the from name.

like image 67
Jey Geethan Avatar answered Oct 28 '25 01:10

Jey Geethan