2011-06-10 11 views
6

Non riesco a eseguire il comando ar_sendmail dal mio terminale. Non penso di aver perso la sua configurazione. Di seguito è riportato il mio codice;Il comando ar_sendmail non funziona con ruby ​​1.9.2

 
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 => "[email protected]", 
    :password => "kathmandu", 
    :enable_starttls_auto => true 
} 
require "action_mailer/ar_mailer" 
Gemfile 
+++++++++++++++++++++++++++ 
gem "ar_mailer", "1.5.1"
My Mailer 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
class Postoffice < ActionMailer::ARMailer 
    def recover_password_email(account, name, address) 
    @recipients = address 
    @from = "[email protected]" 
    @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 

Ogni volta che corro comando ar_sendmail ottengo solo sotto il messaggio. Se ho colpito RAILS_ROOT in consolle poi mi mostra /Users/me/Dev/a5his

 
Usage: ar_sendmail [options] 

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

ar_sendmail must be run from a Rails application's 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's 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's root to deliver email. 

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

Grazie in anticipo <> <

risposta

0

Prova ar_sendmail --chdir /Users/me/Dev/a5his o cambiare nella root del vostro rotaie applicazione prima di eseguire il comando

+0

Quando raggiungo RAILS_ROOT in console, mostra/Users/me/Dev/a5his. Non significa che sono nella root della mia app? – a5his

+0

Non ha funzionato però !!! – a5his

1

Non sono sicuro se farebbe la differenza, ma dice here mettere

require "action_mailer/ar_mailer" 

in environment.rb, non development.rb o production.rb. Oltre a questo, non riesco a vedere nulla che ti sia sfuggito.

+0

Penso che non importi se mettiamo il codice sopra in development.rb invece di environment.rb. Grazie per la risposta. – a5his

0

ar_sendmail deve essere eseguito dalla radice di un'applicazione Rails per fornire e-mail. /Users/me/Dev/a5 questo non sembra essere una root dell'applicazione Rails.

Si sta eseguendo il comando nella radice dell'applicazione?

+0

Sì, non ci sono dubbi. a5his è la mia cartella principale. – a5his

0

provare

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

Se si guarda alla fonte (vedi sotto), questo messaggio viene visualizzato se il caricamento config/ambiente non riesce. Un'istanza in cui mi sono imbattuto era in cui una dipendenza non era soddisfatta, il che stava causando un'eccezione al fuoco quando veniva caricato config/environment. Per risolvere questo problema, è possibile utilizzare una sessione irb e provare a configurare config/environment per vedere quale errore potrebbe causare l'interruzione della richiesta.

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