I’m working through a contact form from Sinatra Jump Start and trying to figure out why the “From” is always the same gmail account I’m using as the :user_name.
If I’m using :from => params[:name] + "<" + params[:email] + ">"
should I be able to get the email from the form into my inbox and hit reply to that sender’s email? The name shows correctly, but the “From” email address is always the same email as my :user_name
that’s in the :via_options
.
Here’s the send_message method:
def send_message
Pony.mail(
:from => params[:name] + "<" + params[:email] + ">",
:to => 'myemail@gmail.com',
:subject => params[:name] + " has contacted you",
:body => params[:message],
:via => :smtp,
:via_options => {
:address => 'smtp.gmail.com',
:port => '587',
:enable_starttls_auto => true,
:user_name => 'myemail@gmail.com',
:password => 'mypass',
:authentication => 'plain',
:domain => 'localhost.localdomain'
})
end
After some re-reading and thinking about it. It seems like I just need to add the :reply_to
and pass the params[:email]
to it and that gets me the correct reply-to.
I’m still wondering why “From” doesn’t have “sender’s name sender@example.com” but instead shows "sender’s email mygmail@gmail.com.