Skip to content

Send Rails Email from console

I’ve needed to do this forever, and finally found a stack exchange with a nice quick way to send mail from rails console, that works with the version of rails I’m on.

1
2
3
4
5
6
7
8
9
10
11
ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.smtp_settings = {
  address: 'smtp.gmail.com', 
  port: 587, 
  domain: 'gmail.com',
  authentication: 'plain', 
  enable_starttls_auto: true, 
  user_name: 'you@gmail.com',
  password: 'yourpassword'
}
MailNotifier.activation_instructions(@user).deliver
Published inRoRScripting

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *