开发者

Rails 3: My smtp message headers won't take the :from => sender.email

so heres my info to start

config/initializers/mailer.rb

ActionMailer::Base.smtp_settings = {  
  :address              => "smtp.gmail.com",  
  :port                 => 587,  
  :domain               => "mydomain.com",  
  :user_name            => "myUser",  
  :password             => "secret",  
  :authentication       => "plain",  
  :enable_starttls_auto => true  
}

ActionMailer::Base.delivery_method = :smtp

app/mailers/notifier.rb

class Notifier < ActionMailer::Base
  default :from => "My Company <info@mydomain.com>"

   def contact_notification(sender)
     @sender = sender
     mail(
         :to => "info@mydomain",
         :from => sender.email,
         :subject => "Message from #{sender.fullName} on Mydomain.com")
   end
end

My issue, whenever the emails get sent to me they show the smtp account as the from header email address instead of the senders email. So I can't just hit reply to reply to the senders email account.

Any Help would be appreciated.

Up-Date

With the the insite given I found a way to set the Reply-to email Header which did the trick.

Instead of using:

:from => sender.email,

I used

:reply_to => sender.email,
开发者_运维问答

Hope this helps anyone else out there.


This seems specific to the gmail SMTP server see the information here:

http://mail.google.com/support/bin/answer.py?hl=en&answer=22370

This is the applicable section:

Note for IMAP/POP users: If you access Gmail through a POP or IMAP email client (e.g. Outlook) and would like to send messages with a custom "from" address, you have two options. We recommend that you configure your email client with two outgoing SMTP servers, one for Gmail and one for your other address. Your second option is to use Gmail's outbound servers with a different "from" address. If you've already configured the custom from address in the web interface, your message will be sent from:otheraddress@domain.com, sender:username@gmail.com, regardless of which custom from configuration you chose. Your messages will be sent from your regular Gmail address if you never configured your custom from settings in the web interface.

Other than setting that in the web interface for gmail as it suggests, have you tried the Reply-To header? That might work

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜