Rails 3:动作邮件程序不使用:from =>参数 [英] Rails 3: action mailer not usng the :from => parameters

查看:87
本文介绍了Rails 3:动作邮件程序不使用:from =>参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在尝试为联系页面运行电子邮件,并且电子邮件通过的很好,但问题是发件人字段不会显示我的:from =>我的邮寄方式。下面的我的恢复密码功能也会发生同样的事情。 smtp设置中发件人字段中保留的电子邮件是 myusername@gmail.com。非常感谢您提供的任何帮助!

Hi guys I'm trying to get emails running for a "Contact" page and the emails are coming through just fine but the problem is that the "from" field won't show my :from => "" that's inside my mailer method. The same thing happens with my recover password function which is below. The email which persists in the 'from' field is "myusername@gmail.com" from the smtp settings. Really appreciate the any help with this!

我正在使用Gmail并设置如下的smtp设置:

I'm using Gmail and setup my smtp settings like this:

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



mailer / user_mailer.rb



mailer/user_mailer.rb

   def reset_password_instructions(user)
     @user = user
     @url  = "http://localhost:3000"
     mail(:to => user.email,
          :from => "test@mydomain.com",
          :subject => "recover your password"
          )
   end
end



views / mailer / rest_password_instructions.html.erb



views/mailer/rest_password_instructions.html.erb

<p>Hello <%= @resource.email %>!</p>

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

<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></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>


推荐答案

Gmail通常不允许您设置 from 字段来发送电子邮件。因此,很多人都转而使用其他邮件服务,例如SendGrid。

Gmail typically doesn't let you set the from field for sending emails. For this reason, a lot of people switch to other mail services like SendGrid.

如果您搜索来自字段的gmail栏,您会很不幸地看到所有其他人过去一直为此苦苦挣扎。

If you google "Rails gmail from field" you'll unfortunately see all the other people who have struggled with this in the past.

这篇关于Rails 3:动作邮件程序不使用:from =&gt;参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆