I'm using Rails 3.2, and when I try using UserMailer
to send an email, it gives me the error:
"Errno::ECONNREFUSED (No connection could be made because the target machine actively refused it. - connect(2))"
on this line:
UserMailer.welcome_email(@user).deliver
This is the create
function the email is supposed to be delivered in:
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
Does anyone know how to fix this problem? I'm pretty sure I've been able to send emails fine before.
Found the issue, it seems I forgot to add setup_mail.rb under config/initializers.