railsappslearn-ruby-on-rails

When sending an email through my Rails app using ActionMailer I get the email from myself despite of specifying the 'from:' argument


I am following the Learn Ruby on Rails book from the RailsApps project. On Chapter 23 we add the send mail functionality to the app. Everything seems to be working fine expect that the email I receive comes from my own e-mail (regardless of the email I type in the contact form).

It is strange because in the server log, the "sender" seems to be ok. However when I check my e-mail online (gmail) it appears as if I was both the sender and the recipient.

Here is the code from the server log:

Started POST "/contacts" for ::1 at 2015-03-02 14:06:09 -0500
Processing by ContactsController#create as HTML
Parameters: {"utf8"=>"✓",     "authenticity_token"=>"XRDoCx9oADWIWAKWRGgmQSaWaN0HLa8JywAsaNS/4N1YPlME9Z2gtEk6hQikwwrLWPDOtNoL9NfABUO2PGOYwQ==", "contact"=>{"name"=>"John Doe", "email"=>"j.doe@jd.com", "content"=>"Hello world!"}, "commit"=>"Submit"}

WARNING: GoogleDriveV0.login is deprecated and will be removed in the next version. Use GoogleDriveV0.login_with_oauth instead.

DEPRECATION WARNING: `#deliver` is deprecated and will be removed in Rails 5. Use `#deliver_now` to deliver immediately or `#deliver_later` to deliver through Active Job. (called from create at /Users/SergioRodriguez/workspace/learn-rails/app/controllers/contacts_controller.rb:17)
Rendered user_mailer/contact_email.html.erb (0.1ms)
Rendered user_mailer/contact_email.text.erb (0.1ms)

UserMailer#contact_email: processed outbound mail in 37.5ms

Sent mail to my.email@gmail.com (2314.6ms)
Date: Mon, 02 Mar 2015 14:08:03 -0500
From: j.doe@jd.com
To: my.email@gmail.com

Any idea of what is going on?


Solution

  • See the answer: change sender address when sending mail through gmail in c#

    Gmail doesn't allow you to change the FROM to something different than your gmail account.

    It doesn't matter what you use, they over-write it, before they relay it on. This prevent spamming/spoofing.