开发者

Email sending in devise

Please, can you help me. How can i send emails from localhost in devise. For example i write开发者_开发技巧 in development enviroment

 config.action_mailer.default_url_options = { :host => 'localhost:3000' }

But it doesn't send emails on my address for example.


You will need to setup an initializer for you to send email in development enviroment.

Place this configuration in: config/initializers/mail.rb

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "gmail.com",
  :user_name            => "username",
  :password             => "password",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

NOTE: This configuration is for Gmail,if you are not using Gmail you will need to modify the setting for your SMTP client.

Remember that you need to restart your server after adding this file to your rails app.

There is also a great Railscast episode tha will help you here.


#this works well
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_sent_at, :datetime
add_column :users, :unconfirmed_email, :string

#But this cannot work !!!
add_column :users, :confirmation_token, :string, :null => false, :default => ''
add_column :users, :confirmed_at, :datetime, :null => false, :default => '1970-01-01'
add_column :users, :confirmation_sent_at, :datetime, :null => false, :default => '1970-01-01'
add_column :users, :unconfirmed_email, :string, :null => false, :default => ''

See this issue: https://github.com/plataformatec/devise/issues/2567

I catch an issue today and I spend 5 hours on it. Devise 's confirmation email cannot work when the confirmation_token relational columns is blank. Well when the columns is null it works well.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜