Can I send emails from different addresses using the same ActionMailer

I am using ActionMailer for my Rails 2.3.9 application.

When I send an email using:

  deliver_user_invite

configurations:

  def user_invite(subject, content)
    subject subject
    from "User Invite <invite@mydomain.com>"
    recipients "invites@mydomain.com"
    sent_on Time.now
    content_type "text/html"
    body :content => content
  end

with SMTP configuration

  config.action_mailer.smtp_settings = {
      :enable_starttls_auto => true,
      :address        => 'smtp.gmail.com',
      :port           => 587,
      :domain         => 'mydomain.com',
      :authentication => :plain,
      :user_name      => 'user@mydomain.com',
      :password       => 'password'    
  }

However, when sending an e-mail, the sender displays as user@mydomain.com , not invite@mydomain.com.

Can I have a different SMTP configuration for different email addresses? or Is there a way to set the sender address from the ActionMailer configuration?

+3
source share
1 answer

SMTP Gmail. /, smtp, from.

smtp , - .

: , Gmail " , ", , , . (. http://www.mobileread.com/forums/showpost.php?p=21093&postcount=1).

+6

Source: https://habr.com/ru/post/1793410/


All Articles