The ar_sendmail command does not work with ruby ​​1.9.2

I cannot run the ar_sendmail command from my terminal. I do not think I missed his configuration. Below is my code;

  development.rb
 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ++
 ActionMailer :: Base.delivery_method =: activerecord
 ActionMailer :: Base.smtp_settings = {
   : address => "smtp.gmail.com",
   : port => 25,
   : domain => "www.google.com",
   : authentication =>: plain,
   : user_name => " ashis.lun@gmail.com ",
   : password => "kathmandu",
   : enable_starttls_auto => true
 }
 require "action_mailer / ar_mailer"
  Gemfile 
 +++++++++++++++++++++++++++++
 gem "ar_mailer", "1.5.1" 
  My mailer
 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++
 class Postoffice & lt ActionMailer :: ARMailer
   def recover_password_email (account, name, address)
     @recipients = address
     @from = " ashis.lun@gmail.com "
     @subject = "Your Account at # {account.org_name} is Ready"
     @body ["subdomain"] = account.subdomain
     @body ["name"] = name
     @body ["org_name"] = account.org_name
     @body ["password"] = password
     @body ["email"] = address
   end
 end
  My controller
 ++++++++++++++++++++++++++++++++++++++++++++++++++++ ++
 def reset_password
     @user = User.find_by_email (params [: email])

     begin
       if @user
         password = get_new_password
         @ user.update_attributes! (: password => password)
         Postoffice.deliver_recover_password_email (@account, @ user.individual.firstname, @ user.email, password)
         flash [: notice] = "Your password has been e-mailed to you. It should show up in a minute!"
         redirect_to '/ sessions / new'      
       end
     rescue
       flash [: notice] = "Sorry, there was a problem resetting your password."
       redirect_to '/ sessions / new'
     end
   end
 end

Whenever I run the ar_sendmail command, I just get below the message. If I pressed RAILS_ROOT in the console, then I show /Users/me/Dev/a5his

  Usage: ar_sendmail [options]

 ar_sendmail scans the email table for new messages and sends them to the
 website configured SMTP host.

 ar_sendmail must be run from a Rails application root or have it specified
 with --chdir.

 If ar_sendmail is started with --pid-file, it will fail to start if the PID
 file already exists or the contents don't match it PID.

 Sendmail options:
     -b, --batch-size BATCH_SIZE Maximum number of emails to send per delay
                                      Default: Deliver all available emails
         --delay DELAY Delay between checks for new mail
                                      in the database
                                      Default: 60
         --max-age MAX_AGE Maxmimum age for an email.  After this
                                      it will be removed from the queue.
                                      Set to 0 to disable queue cleanup.
                                      Default: 604800 seconds
     -o, --once Only check for new mail and deliver once
                                      Default: false
     -p, --pid-file [PATH] File to store the pid in.
                                      Defaults to /var/run/ar_sendmail.pid
                                      when no path is given
     -d, --daemonize Run as a daemon process
                                      Default: false
         --mailq Display a list of emails waiting to be sent

 Setup Options:
         --create-migration Prints a migration to add an Email table
                                      to stdout
         --create-model Prints a model for an Email ActiveRecord
                                      object to stdout

 Generic Options:
     -c, --chdir PATH Use PATH for the application path
                                      Default:.
     -e, --environment RAILS_ENV Set the RAILS_ENV constant
                                      Default: 
     -t, --table-name TABLE_NAME Name of table holding emails
                                      Used for both sendmail and
                                      migration creation
                                      Default: Email
     -v, - [no-] verbose Be verbose
                                      Default: 
     -h, --help You're looking at it


 ar_sendmail must be run from a Rails application root to deliver email.

 / Users / me / Dev / a5his does not appear to be a Rails application root.

Thanks in advance <> <

+6
source share
6 answers

How to use delayed work? I used ar mailer in the past and found deferred work to be a much better solution.

https://github.com/collectiveidea/delayed_job

+2
source

Not sure if this will change, but he is talking here to put

 require "action_mailer/ar_mailer" 

in environment.rb , not development.rb or production.rb . Other than this, I do not see anything that you missed.

+1
source

Try ar_sendmail --chdir /Users/me/Dev/a5his or go to the root of your rails application before running the command

0
source

ar_sendmail must be run from the root of the Rails email delivery application. / Users / me / Dev / a 5his is not the root of the Rails application.

Is the command running at the root of the application?

0
source

try

 cd #{Rails.root.to_s} && bundle exec ar_sendmail_rails3 -e production 
0
source

If you look at the source (see below), this message is displayed if the configuration / environment is not loading. One example of this that I came across was that the dependency was unsatisfied, which caused a fire when the configuration / environment loaded. To solve this problem, you can use an irb session and ask config / environment to display which error might be causing the failure.

 Dir.chdir options[:Chdir] do begin require 'config/environment' rescue LoadError usage opts, <<-EOF #{name} must be run from a Rails application root to deliver email. #{Dir.pwd} does not appear to be a Rails application root. EOF end end 
0
source

Source: https://habr.com/ru/post/890218/


All Articles