"无法建立连接,因为目标计算机主动拒绝它"使用Rails 3.2

时间:2012-09-20 23:03:41

标签: ruby-on-rails ruby actionmailer mailer

我正在使用Rails 3.2,当我尝试使用UserMailer发送电子邮件时,它会给我错误:

"Errno::ECONNREFUSED (No connection could be made because the target machine actively refused it. - connect(2))"

在这一行:

UserMailer.welcome_email(@user).deliver

这是电子邮件应该传递的create函数:

def create
  @user = User.new(params[:user])

  respond_to do |format|
    if @user.save
      UserMailer.welcome_email(@user).deliver
      format.html { redirect_to @user, notice: 'User was successfully created.' }
      format.json { render json: @user, status: :created, location: @user }
    else
      format.html { render action: "new" }
      format.json { render json: @user.errors, status: :unprocessable_entity }
    end
  end
end

有谁知道如何解决这个问题?我很确定我以前能够发好电子邮件。

1 个答案:

答案 0 :(得分:0)

发现问题,似乎我忘了在config / initializers下添加setup_mail.rb。