Rails: change default sender in action mailer

纵饮孤独 提交于 2019-12-05 11:13:08

You can pass it as a parameter to the mail method:

def new_mail
  mail from: "example@example.com", to: "user@example.com"
end

I think you want to send mail with three different emails of the for-each action. Because you use gmail, you need Sending mail from a different address.

No single vendor is optimal for all three types of email; you likely will use several vendors.

For “company email,” that is, sending individual email to customers or business associates, you’ll probably use Gmail or Google Apps for Business. For a single address, you can set up a single Gmail account to receive and send email from a different address. More likely, you’ll want several email addresses for your company mail. For that, use Google Apps for Business.

Send Email with Rails

I found that, this can't be done using smtp. Need to use amazon SES which allows multi sender support.

Here's what i use, it allows to make a "title" different.

class UserMailer < ActionMailer::Base
      default :from => '"example" <example@domain.com>'

      def send_signup_email(user)
        @user = user
        mail(to: @user.email, subject: 'example')
      end
    end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!