i am writing a ruby script to send email using 'mail' gem.
and my smtp settings on my local machine:
mailer_options:
    address: smtp.gmail.com
    port: 465
    domain: gmail.com
    user_name: [email protected]
    password: example_password
    authentication: :login
    enable_starttls_auto: true
    ssl: true
i am trying to send the like this :-----
Mail.deliver do
  to  '[email protected]'
  from    '[email protected]'
  subject 'Test Mail'
  text_part do
    body 'Hello World!!!!!'
  end
end
the mail is send successfully but when i open the email i see sender email id as 
[email protected] instead of [email protected], why it is so i am not able to figure out.
thanks for any comment and answers.
This is often done by your SMTP server and is beyond your control. You could try using a different SMTP provider like Sendgrid if Google isn't working out for you.
Correct answers above, it's not your code, it's the Gmail SMTP servers that do this. I work for SendGrid and if you wanted to change this over to using SendGrid (or any other provider for that matter) then you can do it really easily. Our free plan can send 400 emails a day and is fine for local development.
Your code would change as follows:
mailer_options:
  address: smtp.sendgrid.net
  port: 587
  domain: yourdomain.com
  username: your_username
  password: your_password
  authentication: plain
  enable_starttls_auto: true
You don't need to have SSL set at this stage. From here you can use your original Mail.deliver method.
You'll find you can now send from the [email protected] address, or whichever address you specify in the from attribute.
There's further Ruby & SendGrid details in the SendGrid documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With