I created a contact form and I am well receiving letters in my gApps inbox. However, the messages received show a default value: from the site value. I would like them to appear in the inbox from the email form. Therefore, when I click "reply", it takes the user's address as the address to which you want to send an email.
I tried this, but it does not work. Any idea why?
notifications_mailer.rb
class NotificationsMailer < ActionMailer::Base
default to: "info@hikultura.com"
def new_contact(message)
@message = message
mail(:subject => "[hiKultura.com] #{message.subject}",
:from => message.email)
end
end
ContactController
class ContactController < ApplicationController
def new
@message = Contactmessage.new
end
def create
@message = Contactmessage.new(params[:contactmessage])
if @message.valid?
NotificationsMailer.new_contact(@message).deliver
redirect_to(root_path, :notice => "Message was successfully sent.")
else
flash.now.alert = "Please fill all fields."
render :new
end
end
end
UPDATE
I followed similar cases that I found in SO regarding: reply_to and GMail. But, still shows: to the email address when I hit the answer. What am I missing ???
notifications_mailer.rb
class NotificationsMailer < ActionMailer::Base
default :from => 'no-reply@mydomain.com'
def new_contact(message)
@message = message
mail(:reply_to => "mierda@hotmail.com",
:subject => "[mydomain.com] #{message.subject}",
:to => "admin@mydomain.com"
)
end
end