Search code examples
ruby-on-rails-3emailsmtpemail-headers

Set mailer "from" value to smth arbitrary in Rails


My email address from which I deliver messages is noreply@domain.com, when I send message with:

mail(:from=>'noreply@domain.com', :to=>"somebody@gmail.com", :subject=>"Welcome!")

from field in Gmail shows noreply, so I have tried using following:

mail(:from=>'domain', :to=>"somebody@gmail.com", :subject=>"Welcome!", :return_path=>"noreply@domain.com", :reply_to=>"noreplay@domain.com")

above returns:

554 Message refused.

All I want is that from field was saying something like "MyDomain" or whatever. So how do I do this?

Thanks!


Solution

  • Did you try using

    :from=>'MyDomain <noreply@domain.com>'
    

    If this doesn't work then add a header with key 'FROM' and value in following format:

    From_Name <from_email>