ruby-on-rails - 为什么我不能在我的 Rails 应用程序中使用 Gmail 正确设置 FROM 名称?

标签 ruby-on-rails ruby-on-rails-3 gmail

我正在尝试让我从 Ruby on Rails 应用程序通过 Gmail 发送的电子邮件来自 Ben

目前,当电子邮件到达(单独的、不相关的)Gmail 帐户时,收件箱中的发件人部分有 ben

这是我的设置:

setup_mail.rb

# my domain is my_example.com, and the email address I am sending from is ben@my_example.com
ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "my_example.com",
  :user_name            => "ben@my_example.com",
  :password             => "my_password",
  :authentication       => "plain",
  :enable_starttls_auto => true
}
if Rails.env.development?
    ActionMailer::Base.default_url_options[:host] = "localhost:3000" 
else    
    ActionMailer::Base.default_url_options[:host] = "my_example.com"
end

report_mailer.rb

  def send_notification_email(notification_details)
    subject = "testing_email"
    mail(:to => notification_details[:email], :subject => subject, :from => "Ben")  
  end

下面是 Gmail 中的电子邮件设置: enter image description here

最佳答案

在 :from 部分,您实际上可以这样指定电子邮件地址:

:from => 'Ben <ben@my_example.com>'

关于ruby-on-rails - 为什么我不能在我的 Rails 应用程序中使用 Gmail 正确设置 FROM 名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6224807/

相关文章:

html - 欧元货币符号的 HTML 实体在 GMail 中不可见

php - 无法使用 gmail smtp 和 swift mailer 发送邮件

ruby-on-rails - 如何在没有模型的情况下使用载波?

ruby-on-rails - 大文件上传

ruby-on-rails - Rails 3.0.0.beta 安装问题 : can't find executable rails

ruby-on-rails-3 - 导轨 : No 'field_with_errors' when using 'fields_for'

https - 轻松的反向代理,可通过ssl提供图像

ruby-on-rails - 在 Controller 中的 View VS 中运行昂贵的方法 - Rails

ruby-on-rails - 自定义设计方法 : render 'new' redirect to/users instead of/users/sign_up

ruby-on-rails - mongoid 和 validates_linked 不起作用