开发者

Wrong "from" email when using ActionMailer

开发者 https://www.devze.com 2023-03-21 04:30 出处:网络
Rails 2.3.11 I\'m trying to send an activation-style email whenever a user registers.The email gets sent successfully, but has the wrong \"from\" email address.The subject, content, and recipient\'s

Rails 2.3.11

I'm trying to send an activation-style email whenever a user registers. The email gets sent successfully, but has the wrong "from" email address. The subject, content, and recipient's email are all fine. Instead of being sent from activation@[domain].net, they come from [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

Applicable part of the controller that calls it:

@user = User.create(
          :first_name            => params[:first_name],
          :last_name             => params[:last_name],
          :email                 => params[:email],
          :password              =>开发者_JAVA技巧; 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

Thank you!


This looks like a Bluehost-specific problem. You may need to make sure the activation@[sub].[domain].net e-mail address is actually set up as a full email account with Bluehost (this seems to be a common solution).

0

精彩评论

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

关注公众号