Sender mail is overridden by smtp user_name

I am writing a ruby ​​script to send email using the "mail" gem.

and my smtp settings on my local computer:

mailer_options:
    address: smtp.gmail.com
    port: 465
    domain: gmail.com
    user_name: example@gmail.com
    password: example_password
    authentication: :login
    enable_starttls_auto: true
    ssl: true

I am trying to send like this: -----

Mail.deliver do

  to  'receiver@gmail.com'
  from    'sender@gmail.com'
  subject 'Test Mail'

  text_part do
    body 'Hello World!!!!!'
  end

end

mail is sent successfully, but when I open the letter, I see the sender ID of the email as example@gmail.cominstead of sender@gmail.comwhy it is so, I can’t understand.

Thanks for any comments and answers.

+4
source share
5 answers
+5
source

SMTP- . SMTP-, Sendgrid, Google .

+3

, , SMTP- Gmail, . SendGrid, SendGrid ( , ), . 400 .

:

mailer_options:
  address: smtp.sendgrid.net
  port: 587
  domain: yourdomain.com
  username: your_username
  password: your_password
  authentication: plain
  enable_starttls_auto: true

SSL. Mail.deliver.

sender@yourdomain.com , from.

Ruby SendGrid SendGrid.

+2

Google . GMAIL. !!. gmail, "from_email". "Mandrill" (12000 /). , .

+1

'sender@gmail.com' :

class UserMailer < ActionMailer::Base
  default from: 'sender@gmail.com'

  def welcome_email(user)
    @user = user
    @url  = 'http://example.com/login'
    mail(to: @user.email, subject: 'Welcome to My Awesome Site')
  end
end
0

All Articles