Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails ar_sendmail命令不适用于ruby 1.9.2_Ruby On Rails_Rubygems_Sendmail_Actionmailer_Ar Mailer - Fatal编程技术网

Ruby on rails ar_sendmail命令不适用于ruby 1.9.2

Ruby on rails ar_sendmail命令不适用于ruby 1.9.2,ruby-on-rails,rubygems,sendmail,actionmailer,ar-mailer,Ruby On Rails,Rubygems,Sendmail,Actionmailer,Ar Mailer,我无法从终端运行ar\u sendmail命令。我想我没有错过它的配置。下面是我的代码 development.rb ++++++++++++++++++++++++++++++++++++++++++++++++++++ ActionMailer::Base.delivery_method = :activerecord ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => 25, :

我无法从终端运行
ar\u sendmail
命令。我想我没有错过它的配置。下面是我的代码

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"
提前感谢尝试
ar\u sendmail--chdir/Users/me/Dev/a5his
或者在运行命令之前切换到rails应用程序的根目录中

不确定这是否会产生影响,但它说


environment.rb
中,而不是
development.rb
production.rb
。除此之外,我看不到您遗漏了什么。

使用延迟作业如何?我过去使用过ar mailer,发现延迟工作是一个更好的解决方案


ar\u sendmail必须从Rails应用程序的根目录运行才能发送电子邮件。 /Users/me/Dev/a5his似乎不是Rails应用程序根目录

是否在应用程序的根目录下运行该命令?

请重试

cd #{Rails.root.to_s} && bundle exec ar_sendmail_rails3 -e production
如果查看源代码(如下所示),如果加载配置/环境失败,将显示此消息。我遇到的一个实例是未满足依赖项,这导致在加载config/environment时引发异常。为了解决这个问题,您可以使用irb会话并尝试要求配置/环境来查看导致要求失败的错误

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
Dir.chdir选项[:chdir]do
开始
需要“配置/环境”
救援装载错误

用法选择,当我在控制台中点击RAILS\u ROOT时,它显示/Users/me/Dev/a5his。这不是意味着我是我的应用程序的根吗?谢谢Kevin,延迟的工作是一件非常好的事情。我认为如果我们把上面的代码放在development.rb而不是environment.rb中,那没关系。谢谢你的回复。是的,毫无疑问。这是我的根文件夹。 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 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.
require "action_mailer/ar_mailer"
cd #{Rails.root.to_s} && bundle exec ar_sendmail_rails3 -e production
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