【问题标题】:Rails ActionMailer TSL plugin - Sender email problemRails ActionMailer TSL 插件 - 发件人电子邮件问题
【发布时间】: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


    【解决方案1】:

    Gmail 不允许使用注册以外的邮件地址转发邮件...

    【讨论】:

      【解决方案2】:

      我将投递方式更改为 :sendmail,它开始为我工作 :-)

      ActionMailer::Base.delivery_method = :sendmail

      【讨论】:

        猜你喜欢
        • 2014-12-31
        • 2011-08-11
        • 2010-10-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多