Confused about "From" for Email reading Jump Start Sinatra and Pony:

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.

You are sending the form from your webpage and so the sender is yourself.
If you were opening the senders email software ( using the html mail function? ) and the user was sending from that it would have their email address.

This happens a lot in forums when the user gets an email from another user and uses “reply”. The email is then sent to the forum admin. There is usually a note on the message saying something like “Do not reply to this message but do so in the forum messaging section”.

Thanks for the reply. That makes sense, especially with the context you gave!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.