我已经建立了一个联系我们的表单,我成功地在我的gApps收件箱中收到了电子邮件。然而,接收到的电子邮件显示网站的默认值:from。我希望它们出现在用户在电子邮件字段中输入的电子邮件地址发送的邮件中。因此,当我点击“回复”时,它将以用户地址作为必须发送电子邮件的地址。
我已经尝试过这个方法,但它并没有起作用。有什么想法吗?
notifications_mailer.rb
我已经尝试过这个方法,但它并没有起作用。有什么想法吗?
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
联系人控制器
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
更新
我在 Stack Overflow 上找到了类似的案例,关于 :reply_to 和 GMail 的问题。但是,当我点击回复时仍然显示了 :to 邮箱地址。我漏掉了什么?
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