Rails EOFError (end of file reached) when saving a

2019-04-04 00:53发布

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?

5条回答
家丑人穷心不美
2楼-- · 2019-04-04 01:26

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,
      }
    })
查看更多
小情绪 Triste *
3楼-- · 2019-04-04 01:30

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',

查看更多
爷的心禁止访问
4楼-- · 2019-04-04 01:37

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

查看更多
等我变得足够好
5楼-- · 2019-04-04 01:44

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.

查看更多
Explosion°爆炸
6楼-- · 2019-04-04 01:51

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

查看更多
登录 后发表回答