# @from in emailer.rb not working with rails + gmail

**URL:** <https://www.ruby-forum.com/t/from-in-emailer-rb-not-working-with-rails-gmail/148710>\
**Category:** Rails\
**Created:** [September 16, 2008, 1:38pm UTC](https://www.ruby-forum.com/t/from-in-emailer-rb-not-working-with-rails-gmail/148710 "2008-09-16T13:38:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vmvipin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/c0e974/32.png) [@vmvipin](https://www.ruby-forum.com/u/vmvipin)\
**Post date:** [September 16, 2008, 1:38pm UTC](https://www.ruby-forum.com/t/from-in-emailer-rb-not-working-with-rails-gmail/148710/1 "2008-09-16T13:38:28Z")

</div>

Hi All,

Am trying to send email through gmail in rails. Its working fine. My  
issue is @from is not working. I have assigned @from = ‘removed\_email\_address@domain.invalid’  
in my emailer.rb and :user\_name =\> “removed\_email\_address@domain.invalid” in my  
environment.rb file. When i receive mail, from id is “removed\_email\_address@domain.invalid”  
not “removed\_email\_address@domain.invalid”. When its not gmail and port is 25 its works fine.

class Emailer \< ActionMailer::Base  
def sendmail(subject, email, sent\_at, name, message)  
@from = ‘removed\_email\_address@domain.invalid’  
@subject = subject  
@recipients = email  
@sent\_on = sent\_at  
@body[“name”] = name  
@body[“message”] = message  
end  
end

ActionMailer::Base.delivery\_method = :smtp  
require ‘smtp\_tls’

ActionMailer::Base.smtp\_settings = {  
:address =\> “[smtp.gmail.com](http://smtp.gmail.com)”,  
:port =\> 587,  
:domain =\> “[www.google.com](http://www.google.com)”,  
:user\_name =\> “removed\_email\_address@domain.invalid”,  
:password =\> “mypassword”,  
:authentication =\> :plain  
}

Thanks in advance 🙂

Vipin

---

<div class="post-metadata">

**Author:** ![vmvipin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/c0e974/32.png) [@vmvipin](https://www.ruby-forum.com/u/vmvipin)\
**Post date:** [September 16, 2008, 4:39pm UTC](https://www.ruby-forum.com/t/from-in-emailer-rb-not-working-with-rails-gmail/148710/2 "2008-09-16T16:39:23Z")

</div>

i believe gmail rewrites the from address to help prevent spam. you  
can test this using outlook, thunderbird, etc.  
i think they want you to set the reply to address.
