devise.rb - Net::SMTPSyntaxError when calling send

2019-08-15 17:23发布

问题:

I am getting Net::SMTPSyntaxError 501 Syntax Error when calling the send_reset_password_instructions({:email => 'my@email.com'}) Devise helper. I am using Ruby 1.9.3, Rails 3.2.19 and devise 2.2.8.

A snippet of the calling function:

class UserController
    def reset
        User.send_reset_password_instructions(hash_params) # {:email => 'my@email.com'}

        # ... more code down here ...
    end
end

The User class has the following devise modules activated:

class User
    ...

    devise :registerable, :database_authenticatable, :recoverable,
        :rememberable, :trackable, :validatable, :omniauthable

    ## Devise Fields
    ## Database authenticatable
    field :email,              :type => String, :null => false
    field :encrypted_password, :type => String, :null => false

    ## Recoverable
    field :reset_password_token,   :type => String
    field :reset_password_sent_at, :type => Time

    ## Rememberable
    field :remember_created_at, :type => Time

    ## Trackable
    field :sign_in_count,      :type => Integer
    field :current_sign_in_at, :type => Time
    field :last_sign_in_at,    :type => Time
    field :current_sign_in_ip, :type => String
    field :last_sign_in_ip,    :type => String       

    ...
end

Am I missing something here?

回答1:

well this error is not related to devise..its related to configuration of ActionMailer for SMTP ..Have a look inside and verify the configuration for :smtp for sending mail in development.rb or devise.rb(wherever you have configured)