views:

15

answers:

1

Hi. 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  = "[email protected]"
    @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 => "[email protected]",
  :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 [email protected], and not the user's email. What is wrong?

+1  A: 

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

Lichtamberg
Wow, that sucks :(
Frexuz