【问题标题】:Wrong "from" email when using ActionMailer使用 ActionMailer 时错误的“发件人”电子邮件
【发布时间】:2011-07-20 01:00:59
【问题描述】:

Rails 2.3.11

每当用户注册时,我都会尝试发送激活式电子邮件。电子邮件已成功发送,但“发件人”电子邮件地址错误。主题、内容和收件人的电子邮件都很好。它们不是从 activation@[domain].net 发送的,而是来自 [login-name]@box570.bluehost.com

/app/models/franklin.rb:

class Franklin < ActionMailer::Base
  def activation(user)
    recipients  user.email
    from        "activation@[sub].[domain].net"
    subject     "[Product] Registration"
    body        :user => user
  end
end

调用它的控制器的适用部分:

@user = User.create(
          :first_name            => params[:first_name],
          :last_name             => params[:last_name],
          :email                 => params[:email],
          :password              => params[:password],
          :password_confirmation => params[:password_confirmation],
          :user_class            => "User"
        )
        Franklin.deliver_activation(@user)

/config/environments/development.rb:

# Settings specified here will take precedence over those in config/environment.rb

# In the development environment your application's code is reloaded on
# every request.  This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false

# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true

# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs                         = true
config.action_controller.perform_caching             = false

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :sendmail

谢谢!

【问题讨论】:

    标签: ruby-on-rails sendmail actionmailer


    【解决方案1】:

    这看起来像是 Bluehost 特有的问题。您可能需要确保 activation@[sub].[domain].net 电子邮件地址实际上设置为 Bluehost 的完整电子邮件帐户(这似乎是一种常见的解决方案)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-27
      • 1970-01-01
      • 2012-06-15
      相关资源
      最近更新 更多