【发布时间】:2011-05-02 19:33:33
【问题描述】:
我使用带有 action_mailer_optional_tls 插件的 ActionMailer 通过 Gmail 发送邮件。
这是我的设置:
class InstantMailer < ActionMailer::Base
layout "email"
def support(ticket)
@recipients = "support@domain.com"
@from = ticket.email #this is the user's email
@subject = "[#{ticket.category}] #{ticket.subject}"
@sent_on = Time.now
@body[:ticket] = ticket
content_type "text/html"
end
end
环境:
# Mailer Settings
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:tls => true,
:address => "smtp.gmail.com",
:port => "587",
:domain => "domain.com",
:authentication => :plain,
:user_name => "account@domain.com",
:password => "***"
}
当我从我的服务器向用户发送邮件时,这可以正常工作。
但是,当用户填写联系表单时,from 字段仍然是 account@domain.com,而不是用户的电子邮件。怎么了?
【问题讨论】:
标签: ruby-on-rails gmail actionmailer