21

I'm getting this error in production when trying to create a user (i'm using the devise gem).

EOFError (end of file reached):

I hit this problem before and it was due to my smtp settings using zoho mail.

I believe my configuration below is what fixed the problem:

ActionMailer::Base.delivery_method = :smtp  
ActionMailer::Base.smtp_settings = {            
  :address              => "smtp.zoho.com", 
  :port                 => 465,              
  :domain               => 'example.com',   
  :user_name            => 'user@example.com',
  :password             => 'password',         
  :authentication       => :login,
  :ssl                  => true,
  :tls                  => true,
  :enable_starttls_auto => true    
}

Now we've added SSL to the site and I believe that is what is causing this error to occur now.

Does anyone have any insight into this error or zoho mail smtp settings with SSL?

Catfish
  • 18,876
  • 54
  • 209
  • 353

5 Answers5

39

This error was caused by not having my config/initializers/devise.rb specifying the correct email address for config.mailer_sender.

Catfish
  • 18,876
  • 54
  • 209
  • 353
  • 1
    You just got me out of 2h looking for some sort of solution as to why this exception was being raised. Many thanks! This is one of the weirdest things I ever saw because my conf was working using gmail's smtp servers but not those related to my domain. – Raindal Jan 26 '14 at 23:25
  • 1
    still get the same error with a correct email address set – Phil May 27 '18 at 15:42
4

Also! I made this additional mistake and had the same issue: I used my own domain instead of the mail server domain for the "domain" variable.

Your environment variable should be:

GMAIL_DOMAIN=gmail.com

Or for the example above:

:domain => 'gmail.com',

2

I found one cause for the error here => https://stackoverflow.com/a/40354121/6264112

But this didn't solve my issue. While I wasn't getting any errors, my emails were still not working through Zoho so I found another solution that works perfectly for my needs...

1) Connect Zoho to gmail using SMTP. I setup my zoho email as an alias for my personal gmail account so zoho emails are forwarded to gmail and I can reply to them IN gmail FROM my zoho email address. This should be done anyways so you never have to login to zoho. Just do all emailing from gmail.

2) Connect ActionMailer to gmail account NOT zoho.

config.action_mailer.smtp_settings = {
    :address                          => 'smtp.gmail.com',
    :port                                 => 587,
    :user_name                     => ENV["gmail_username"],
    :password                       => ENV["gmail_password"],
    :authentication                => :plain,
    :enable_starttls_auto     => true
}

Now, I just need to specify the to and from values in the mailer like so:

def notify_admin (message_details)
    @message_details = message_details
    mail(to: "jesse@mydomain.com", subject: "Contact form filled out by: " + message_details[:name], from: message_details[:email])
end

This works when I want to send emails to myself as is the example above when someone submits the contact form.

It ALSO works when I want to send an email from my domain such as when they fill out the lead magnet. All I did was switch the to: and from: addresses.

Community
  • 1
  • 1
Jesse Novotny
  • 704
  • 7
  • 16
  • This is the last resort. I removed the ENV variables and it would work – Fabrizio Bertoglio Mar 01 '17 at 14:47
  • Definitely last ditch effort... But why would ENV variables cause problems? What if you don't want to store passwords in a public repo? – Jesse Novotny Mar 03 '17 at 00:11
  • This error can also occur if you have set the external gmail host to `smtp-relay.gmail.com` - setting it to just `smtp.gmail.com` seems to work fine (in 2017). – jevon Oct 31 '17 at 22:24
1

Here's a working pony gem call.

Pony.mail({
      :to => 'apotonick@gmail.com',
      subject: "Pony ride",
      body: "Awesome!",
      from: "nick@trb.to", # this MUST be the sending Zoho email.

      :via => :smtp,
      :via_options => {
        :address        => 'smtp.zoho.com',
        :port           => '465',
        :enable_starttls_auto => true,
        ssl: true,
        :user_name      => 'nick@trb.to', # MUST be identical to :from.
        :password       => 'yourStrongPw',
        :authentication => :login,
      }
    })
apotonick
  • 520
  • 2
  • 9
0

I had this issue, and I tried everything and still couldn't figure out what the issue was.

Let's face it, it's a SH!t message. What I did find though I was running my rails app locally with POW and its actually a POW error.

When I run rails server and do the same thing that caused the error, I actually got the real error message and was able to find I hadn't setup my controller correctly

Phil
  • 765
  • 2
  • 8
  • 26