Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes a End Of File Error when Rails Mailer sends an email?

A Rails 3.2.8 application developed with a gmail account as the "sending address". When mail sending works my environment.rb file contains this:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
   :address => "smtp.gmail.com",       
   :port =>  587,                         
   :domain => "gmail.com",              
   :authentication => :login,            
   :user_name => "accountname",         
   :password => "123456789"              
}

I get this message in my application log: EOFError (end of file reached): when the above code is changed to what is shown below:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
   :address => "mail.company.com",
   :port =>   25,   
   :domain => "company.com", 
   :authentication =>   :login,
   :user_name =>  "accountname", 
   :password => "123456789"
}

I can tell you I -am- able to send a manual email message to the email address and see it arrive when using a email client such as ThunderBird, thus I know the [email protected] is functional.

I don't understand how an end of file error comes into play. I also cannot figure out how to get more information to appear in the log.

I look forward to reading a few suggestions of determining the cause of the End Of File.

Started POST "/sendInvites?locale=en&lot_id=18&user_id=17" for 99.99.99.99 at 2013-10-03 08:52:09 -0700
Processing by WaitingListsController#sendInvites as HTML
  Parameters: {"authenticity_token"=>"uwz/6pW1rLPXR4gU3m3OwCmU0O3DSJ/haNM2/ai+OR8=", "locale"=>"en", "lot_id"=>"18", "user_id"=>"17"}
=======>>>> Beginning Send Invitation Process <<<<=======
=======>>>> just before the  PassEmailer.requestApprovedWL IS called to send the invitation <<<<=======
>>>> Beginning ::: requestApprovedWL(user_info) <<<<=======
  Rendered pass_emailer/requestApprovedWL.erb (0.9ms)
>>>> at the end of ::: requestApprovedWL(user_info) <<<<=======
Completed 500 Internal Server Error in 1718ms

EOFError (end of file reached):
  app/controllers/waiting_lists_controller.rb:276:in `sendInvites'
like image 628
Allen Roulston Avatar asked Oct 03 '13 14:10

Allen Roulston


1 Answers

For anyone still experiencing this issue, Whenever appears to default to Production. It is using your Production variables (or looking for them) while in your Development or Staging. Also, per the docs it does not load the Rails environment.

While you are in development or staging you must manually let schedule.rb know this. After finding the File.expand_path method here, the following is how I start my schedule.rb file:

require File.expand_path(File.dirname(__FILE__) + "/environment")
set :environment, Rails.env 
set :output, Rails.root.join('log','cron.log')

This provides you the Rails environment and allows you to also set the path for logging.

like image 61
earth2jason Avatar answered Oct 24 '22 14:10

earth2jason