开发者

Rails ActionMailer TSL plugin - Sender email problem

I use ActionMailer with the action_mailer_optional_tls plugin to send mails via Gmail.

Here is my setup:

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

Environment:

# 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 => "***"
}

This works fine when I send mail from my server to a user.

However, when a user fills in a contact form, the from field is still account@domain.com, and not the user's email. Wh开发者_开发问答at is wrong?


Gmail doesnt allow to relay mails with mailadresses other than the registered...


I changed delivery method to :sendmail and it started to work for me :-)


ActionMailer::Base.delivery_method = :sendmail

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜