Jay Godse
Jay Godse

Reputation: 15503

Rails 3.2: Devise: Email Name

I have a Rails 3.2 application which uses Devise for authentication.

I would like the confirmation email for signups to have "Foo Signups" as the from: email name and "[email protected]" as the email address. Right now, I just have "[email protected]" as the from: email address.

My config looks like this:

# in the file config/initializers/devise.rb
Devise.setup do |config|
  config.mailer_sender="[email protected]"

# etc...

and

# 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"]
}

where GMAIL_ADDRESS and GMAIL_PASSWORD are my Gmail user and password as environment variables and different from [email protected].

How do I configure SMTP or Devise to make "Foo Signups" as the email name and "[email protected]" as the email address?

Upvotes: 0

Views: 42

Answers (1)

jameswilliamiii
jameswilliamiii

Reputation: 878

With ActionMailer you can set your from email address similar to "#{@user.name} <#{@user.email}>"

I have not tried this in Devise, but I would think the same thought process would work for the config since I am sure it is just sending that info along to ActionMailer:

Devise.setup do |config|
  config.mailer_sender= "Foo Signups <[email protected]>"
  #...
end

Upvotes: 1

Related Questions