保存设计用户时,Rails EOFError(到达文件末尾)

时间:2013-05-29 16:55:39

标签: ruby-on-rails ruby-on-rails-3 smtp zoho

我在尝试创建用户时遇到了这个错误(我正在使用设计宝石)。

EOFError (end of file reached):

之前我遇到过这个问题,这是由于我使用zoho邮件进行smtp设置。

我相信我的配置是解决问题的原因:

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    
}

现在我们已经在网站上添加了SSL,我相信这就是导致此错误发生的原因。

有没有人对使用SSL的此错误或zoho邮件smtp设置有任何了解?

5 个答案:

答案 0 :(得分:37)

此错误是由于我的config / initializers / devise.rb没有为config.mailer_sender指定正确的电子邮件地址引起的。

答案 1 :(得分:3)

另外!我犯了这个额外的错误并遇到了同样的问题:我使用自己的域而不是邮件服务器域来获取“域”变量。

您的环境变量应为:

GMAIL_DOMAIN=gmail.com

或者上面的示例:

:domain => 'gmail.com',

答案 2 :(得分:1)

这是一个有效的pony宝石电话。

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,
      }
    })

答案 3 :(得分:1)

我在这里找到了错误的一个原因=> https://stackoverflow.com/a/40354121/6264112

但这并没有解决我的问题。虽然我没有收到任何错误,但我的电子邮件仍未通过Zoho工作,因此我找到了另一种完全符合我需求的解决方案......

1)使用SMTP将Zoho连接到gmail。我将我的zoho电子邮件设置为我的个人Gmail帐户的别名,以便将zoho电子邮件转发到gmail,我可以通过我的zoho电子邮件地址回复它们。无论如何都应该这样做,所以你永远不必登录zoho。只需从gmail发送所有电子邮件。

2)将ActionMailer连接到gmail帐户NOT zoho。

import React from 'react';
import { expect, assert } from 'chai';
import { shallow, mount } from 'enzyme';
import TaskList from './src/components/task_list';
import TaskItem from './src/components/task_item';

describe('TaskList', () => {
    it('should render TaskItem', () => {
        const wrapper = shallow(<TaskList />);
        expect(wrapper.containsAllMatchingElements([
            <TaskItem />,
        ])).to.equal(true);
    });
    it('should exists', () => {
        assert.isDefined(TaskList)
    })
});
describe('TaskItem', () => {
    it('should render one item of unordered list', () => {
        const item = mount(<TaskItem />);
        expect(item).to.contain('li');
    });
    it('should exists', () => {
        assert.isDefined(TaskList)
    })
});

现在,我只需要在邮件程序中指定to和from值,如下所示:

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
}

如果有人提交联系表单,我希望像上面的例子一样向自己发送电子邮件。

当我想从我的域发送电子邮件时,例如当他们填写铅磁铁时,它也可以工作。我所做的就是切换到:和来自:地址。

答案 4 :(得分:0)

我遇到了这个问题,我尝试了一切,仍然无法弄清问题是什么。

让我们面对现实,这是一条SH!t消息。我发现虽然我在POW本地运行我的rails应用程序,但实际上是POW错误。

当我运行rails server并执行导致错误的相同操作时,我实际上收到了真正的错误消息,并且能够找到我没有正确设置控制器