Ruby on rails Rails 3:无法使用自定义:发件人=>地址发送电子邮件

Ruby on rails Rails 3:无法使用自定义:发件人=>地址发送电子邮件,ruby-on-rails,ruby-on-rails-3,smtp,gmail,actionmailer,Ruby On Rails,Ruby On Rails 3,Smtp,Gmail,Actionmailer,我正在尝试发送电子邮件,但电子邮件永远不会使用my:from=>代码,而是使用gmail smtp设置中的“from”来发送电子邮件。例如,电子邮件到达时说:email@gmail.com而不是来自:support@mydomain.com,并在日志中显示使用发件人发送的电子邮件:contact@mydomain.com这是我发明的初始化器 我怎样才能解决这个问题?现在真让人心烦:谢谢你的帮助 我正在使用Gmail并按如下方式设置smtp设置: 配置/初始化器/邮件设置 mailer/user_

我正在尝试发送电子邮件,但电子邮件永远不会使用my:from=>代码,而是使用gmail smtp设置中的“from”来发送电子邮件。例如,电子邮件到达时说:email@gmail.com而不是来自:support@mydomain.com,并在日志中显示使用发件人发送的电子邮件:contact@mydomain.com这是我发明的初始化器

我怎样才能解决这个问题?现在真让人心烦:谢谢你的帮助

我正在使用Gmail并按如下方式设置smtp设置:

配置/初始化器/邮件设置 mailer/user_mailer.rb 日志
Gmail正在改变你的身份。如果您不想修改,请使用自己的邮件服务器

在使用邮件界面和/或谷歌服务器时,有一个关于如何设置不同发件人的问题

IMAP/POP用户注意:如果您通过POP或IMAP电子邮件客户端(如Outlook)访问Gmail,并希望发送带有自定义发件人地址的邮件,则您有两种选择。我们建议您将电子邮件客户端配置为两个传出SMTP服务器,一个用于Gmail,另一个用于其他地址。或者,您也可以使用Gmail的出站服务器,使用不同的发件人地址。如果您已经配置了备用地址,您的邮件将从以下地址发送:otheraddress@domain.com,发件人:username@gmail.com,而不管您选择了哪个自定义配置

你必须先为gmail启用你的第三方地址。检查上面链接的导轨。
IIRC-gmail将设置不同的地址,但是用户仍然会看到它来自gmail。

它真的只是gmail吗?在线上有很多教程,包括railscasts,其中显示了如何使用gmail smtp进行配置,但也在mailer方法中使用自定义:from=>进行配置?
ActionMailer::Base.smtp_settings = {
     :address              => "smtp.gmail.com",
     :port                 => 587,
     :domain               => "mydomain.com",
     :user_name            => "email@gmail.com",
     :password             => "mypassword",
     :authentication       => "plain",
     :enable_starttls_auto => true
     }
   def reset_password_instructions(user)
     @user = user
     @url  = "http://localhost:3000"
     mail(:to => user.email,
          :from => "support@mydomain.com",
          :subject => "recover your password"
          )
   end
end
Started GET "/users/password/new" for 127.0.0.1 at 2011-12-04 12:03:22 -0700
  Processing by Devise::PasswordsController#new as HTML
Rendered devise/shared/_links.erb (1.7ms)
Rendered devise/passwords/new.html.erb within layouts/application (2103.3ms)
Completed 200 OK in 2122ms (Views: 2112.1ms | ActiveRecord: 0.8ms)


Started POST "/users/password" for 127.0.0.1 at 2011-12-04 12:03:27 -0700
  Processing by Devise::PasswordsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"hEYh1/G9P0noE+VobBbgremT+rpt+fJFez7H99dOGNM=", "user"=>{"email"=>"barry269@gmail.com"}, "commit"=>"Send me reset password instructions"}
  User Load (1.7ms)  SELECT "users".* FROM "users" WHERE "users"."email" = 'barry269@gmail.com' LIMIT 1
Rendered devise/mailer/reset_password_instructions.html.erb (1.0ms)

Sent mail to barry269@gmail.com (3585ms)
Date: Sun, 04 Dec 2011 12:03:28 -0700
From: contact@mydomain.com
Reply-To: contact@mydomain.com
To: barry269@gmail.com
Message-ID: <4edbc4008ace9_5ab8153b1c470979@ihal-MacBook-Pro.local.mail>
Subject: Reset password instructions
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<p>Hello barry269@gmail.com!</p>

<p>Someone has requested a link to change your password, and you can do this through the link below.</p>

<p><a href="http://localhost:3000/users/password/edit?reset_password_token=Gg3Aqe6sFD3rDLUAda47">Change my password</a></p>

<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
Redirected to http://localhost:3000/users/sign_in
Completed 302 Found in 4281ms


Started GET "/users/sign_in" for 127.0.0.1 at 2011-12-04 12:03:32 -0700
  Processing by Devise::SessionsController#new as HTML
Rendered devise/shared/_links.erb (1.7ms)
Rendered devise/sessions/new.html.erb within layouts/application (80.7ms)
Completed 200 OK in 340ms (Views: 90.6ms | ActiveRecord: 2.3ms)