raphael_turtle
raphael_turtle

Reputation: 7314

Rails mailer alternate from address

I can set a default from address in a rails like so;

    class UserMailer < ActionMailer::Base
      default :from => "\"Company\" <[email protected]>"

      def custom_address(user)
        # I want to set the from address here
        mail(to: user.email, subject: 'Custom from address')
      end
    end

but how do I set a custom address for a different method? I can't see it listed anywhere in the docs

Upvotes: 0

Views: 50

Answers (1)

sabrams
sabrams

Reputation: 1128

I may be wrong, but I believe you can just override the from within the mail method.

class UserMailer < ActionMailer::Base
          default :from => "\"Company\" <[email protected]>"

          def custom_address(user)
            # I want to set the from address here
            mail(to: user.email, subject: 'Custom from address', from: '[email protected]')
          end
        end

Upvotes: 1

Related Questions