Grégoire Borel
Grégoire Borel

Reputation: 2038

Changer ActionMailer sender address

When a User is connected and creates a new Vacation, an email must be send to chosen validator of the Vacation. Here's my current ActionMailer:

class UserNotifier < ActionMailer::Base
  default from: "[email protected]"

  def send_validation_vacation_email(user, receiver, vacation)
   @user = user
   @receiver = receiver
   @vacation = vacation
   mail(:to => receiver.email, :subject => 'Blabla')
  end
end

As you can see, I'm able to get all the data I need. However, I don't know how to setup the ActionMailer so that the sender address can be changed.

Do I need to connect the ActionMailer to the User model?

Upvotes: 0

Views: 154

Answers (1)

Ashutosh Tiwari
Ashutosh Tiwari

Reputation: 998

You can use from in specific method/mailer where you want to change sender address(do not want to use default sender).
Try this one:

mail(:to => receiver.email, :subject => 'Blabla', :from => user.email)

Upvotes: 1

Related Questions