English 中文(简体)
发送电子邮件使用邮件时的档案错误 表格
原标题:End of file (EOF) error when delivering an email using Mail_Form gem

我有一个简单的接触物体表格。

  <%= simple_form_for @contact do |f| %>
    <%= f.input :name %>
    <%= f.input :email %>
    <%= f.input :message %>
    <%= f.button :submit %>
  <% end %>
class Contact < MailForm::Base
    attribute :name, validate: true
    attribute :email, validate: true
    attribute :message  
    def headers
      { 
        subject: "My Contact Form",
        to:  #####gmail.com ,
        from: %("#{name}" <#{email}>)
      }
    end
  end

该物体按预期创建,但在通过联系控制器发送邮件时使用......。 交付

class ContactsController < ApplicationController
    def create
      @contact = Contact.new()
      @contact.name = [:name]
      @contact.email = [:email]
      @contact.message = [:message]
      if @contact.deliver
        render json: {message: "Email sent successfully"}
      else
        render json: @contact.errors
      end
    end
  end

我有以下错误:接触者中的低地轨道探测器。

当我试图在独立监管机构内打一个接触物体时,它向我提供以下信息:

  Rendering /home/#####/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mail_form-1.10.0/lib/mail_form/views/mail_form/contact.erb
  Rendered /home/#####/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mail_form-1.10.0/lib/mail_form/views/mail_form/contact.erb (Duration: 7.3ms | Allocations: 1861)
MailForm::Notifier#contact: processed outbound mail in 62.3ms
Delivered mail [email protected] (192.0ms)
Date: Sat, 22 Apr 2023 20:00:30 +0100
From: ##### <#####@hello.com>
To: #############@gmail.com
Message-ID: <[email protected]>
Subject: My Contact Form
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<h4 style="text-decoration:underline">My Contact Form</h4>


  <p><b>Name:</b>
  #####</p>

  <p><b>Email:</b>
  #####@hello.com</p>

  <p><b>Message:</b>
  #####</p>


/home/#####/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:237:in `rbuf_fill : end of file reached (EOFError)

我在发展中的 set。 页: 1

 config.action_mailer.perform_deliveries = true
  config.action_mailer.default_url_options = { host:  localhost:3000  }
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
  address:  smtp-relay.gmail.com ,
  port: 587,
  domain:  @gmail.com ,
  authentication:  plain ,
  enable_starttls_auto: true,
  user_name: ENV[ username ],
  password: ENV[ password ]

我对此表示赞赏,这是在这里倾斜的许多法典,但我确实是在我的证人结束这一问题的时候。 如果任何人需要任何进一步的信息帮助,请让我知道。

到目前为止,我已经尝试研究观察员部队的错误,但由于错误信息非常简短,因此实际上已经有限。 我大力改变港口和当地东道地址,但似乎没有工作。

错误页的参数如下:

(8) "authenticity_token”=>"[FILTERED],“contact”=>{“etname”=>”fff”、“email”=>“message”=>“fff”},“commit”=>“CreateLink”}

完整跟踪:

net-protocol (0.2.1) lib/net/protocol.rb:237:in `rbuf_fill 
net-protocol (0.2.1) lib/net/protocol.rb:199:in `readuntil 
net-protocol (0.2.1) lib/net/protocol.rb:209:in `readline 
net-smtp (0.3.3) lib/net/smtp.rb:1057:in `recv_response 
net-smtp (0.3.3) lib/net/smtp.rb:1042:in `block in getok 
net-smtp (0.3.3) lib/net/smtp.rb:1067:in `critical 
net-smtp (0.3.3) lib/net/smtp.rb:1040:in `getok 
net-smtp (0.3.3) lib/net/smtp.rb:935:in `helo 
net-smtp (0.3.3) lib/net/smtp.rb:703:in `do_helo 
net-smtp (0.3.3) lib/net/smtp.rb:660:in `do_start 
net-smtp (0.3.3) lib/net/smtp.rb:611:in `start 
mail (2.8.1) lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session 
mail (2.8.1) lib/mail/network/delivery_methods/smtp.rb:100:in `deliver! 
mail (2.8.1) lib/mail/message.rb:2145:in `do_delivery 
mail (2.8.1) lib/mail/message.rb:253:in `block in deliver 
actionmailer (7.0.4.3) lib/action_mailer/base.rb:588:in `block in deliver_mail 
activesupport (7.0.4.3) lib/active_support/notifications.rb:206:in `block in instrument 
activesupport (7.0.4.3) lib/active_support/notifications/instrumenter.rb:24:in `instrument 
activesupport (7.0.4.3) lib/active_support/notifications.rb:206:in `instrument 
actionmailer (7.0.4.3) lib/action_mailer/base.rb:586:in `deliver_mail 
mail (2.8.1) lib/mail/message.rb:253:in `deliver 
actionmailer (7.0.4.3) lib/action_mailer/message_delivery.rb:119:in `block in deliver_now 
actionmailer (7.0.4.3) lib/action_mailer/rescuable.rb:17:in `handle_exceptions 
actionmailer (7.0.4.3) lib/action_mailer/message_delivery.rb:118:in `deliver_now 
mail_form (1.10.0) lib/mail_form/delivery.rb:158:in `deliver! 
activesupport (7.0.4.3) lib/active_support/callbacks.rb:400:in `block in make_lambda 
activesupport (7.0.4.3) lib/active_support/callbacks.rb:236:in `block in halting_and_conditional 
activesupport (7.0.4.3) lib/active_support/callbacks.rb:599:in `block in invoke_after 
activesupport (7.0.4.3) lib/active_support/callbacks.rb:599:in `each 
activesupport (7.0.4.3) lib/active_support/callbacks.rb:599:in `invoke_after 
activesupport (7.0.4.3) lib/active_support/callbacks.rb:108:in `run_callbacks 
mail_form (1.10.0) lib/mail_form/shim.rb:49:in `deliver 
app/controllers/contacts_controller.rb:7:in `create 
actionpack (7.0.4.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action 
actionpack (7.0.4.3) lib/abstract_controller/base.rb:215:in `process_action 
actionpack (7.0.4.3) lib/action_controller/metal/rendering.rb:53:in `process_action 
actionpack (7.0.4.3) lib/abstract_controller/callbacks.rb:234:in `block in process_action 
activesupport (7.0.4.3) lib/active_support/callbacks.rb:118:in `block in run_callbacks 
actiontext (7.0.4.3) lib/action_text/rendering.rb:20:in `with_renderer 
actiontext (7.0.4.3) lib/action_text/engine.rb:69:in `block (4 levels) in <class:Engine> 
activesupport (7.0.4.3) lib/active_support/callbacks.rb:127:in `instance_exec 
activesupport (7.0.4.3) lib/active_support/callbacks.rb:127:in `block in run_callbacks 
activesupport (7.0.4.3) lib/active_support/callbacks.rb:138:in `run_callbacks 
actionpack (7.0.4.3) lib/abstract_controller/callbacks.rb:233:in `process_action 
actionpack (7.0.4.3) lib/action_controller/metal/rescue.rb:22:in `process_action 
actionpack (7.0.4.3) lib/action_controller/metal/instrumentation.rb:67:in `block in process_action 
activesupport (7.0.4.3) lib/active_support/notifications.rb:206:in `block in instrument 
activesupport (7.0.4.3) lib/active_support/notifications/instrumenter.rb:24:in `instrument 
activesupport (7.0.4.3) lib/active_support/notifications.rb:206:in `instrument 
actionpack (7.0.4.3) lib/action_controller/metal/instrumentation.rb:66:in `process_action 
actionpack (7.0.4.3) lib/action_controller/metal/params_wrapper.rb:259:in `process_action 
activerecord (7.0.4.3) lib/active_record/railties/controller_runtime.rb:27:in `process_action 
actionpack (7.0.4.3) lib/abstract_controller/base.rb:151:in `process 
actionview (7.0.4.3) lib/action_view/rendering.rb:39:in `process 
actionpack (7.0.4.3) lib/action_controller/metal.rb:188:in `dispatch 
actionpack (7.0.4.3) lib/action_controller/metal.rb:251:in `dispatch 
actionpack (7.0.4.3) lib/action_dispatch/routing/route_set.rb:49:in `dispatch 
actionpack (7.0.4.3) lib/action_dispatch/routing/route_set.rb:32:in `serve 
actionpack (7.0.4.3) lib/action_dispatch/journey/router.rb:50:in `block in serve 
actionpack (7.0.4.3) lib/action_dispatch/journey/router.rb:32:in `each 
actionpack (7.0.4.3) lib/action_dispatch/journey/router.rb:32:in `serve 
actionpack (7.0.4.3) lib/action_dispatch/routing/route_set.rb:852:in `call 
rack (2.2.6.4) lib/rack/tempfile_reaper.rb:15:in `call 
rack (2.2.6.4) lib/rack/etag.rb:27:in `call 
rack (2.2.6.4) lib/rack/conditional_get.rb:40:in `call 
rack (2.2.6.4) lib/rack/head.rb:12:in `call 
actionpack (7.0.4.3) lib/action_dispatch/http/permissions_policy.rb:38:in `call 
actionpack (7.0.4.3) lib/action_dispatch/http/content_security_policy.rb:36:in `call 
rack (2.2.6.4) lib/rack/session/abstract/id.rb:266:in `context 
rack (2.2.6.4) lib/rack/session/abstract/id.rb:260:in `call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/cookies.rb:704:in `call 
activerecord (7.0.4.3) lib/active_record/migration.rb:603:in `call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call 
activesupport (7.0.4.3) lib/active_support/callbacks.rb:99:in `run_callbacks 
actionpack (7.0.4.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/executor.rb:14:in `call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call 
web-console (4.2.0) lib/web_console/middleware.rb:132:in `call_app 
web-console (4.2.0) lib/web_console/middleware.rb:28:in `block in call 
web-console (4.2.0) lib/web_console/middleware.rb:17:in `catch 
web-console (4.2.0) lib/web_console/middleware.rb:17:in `call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/show_exceptions.rb:26:in `call 
railties (7.0.4.3) lib/rails/rack/logger.rb:40:in `call_app 
railties (7.0.4.3) lib/rails/rack/logger.rb:25:in `block in call 
activesupport (7.0.4.3) lib/active_support/tagged_logging.rb:99:in `block in tagged 
activesupport (7.0.4.3) lib/active_support/tagged_logging.rb:37:in `tagged 
activesupport (7.0.4.3) lib/active_support/tagged_logging.rb:99:in `tagged 
railties (7.0.4.3) lib/rails/rack/logger.rb:25:in `call 
sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/remote_ip.rb:93:in `call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/request_id.rb:26:in `call 
rack (2.2.6.4) lib/rack/method_override.rb:24:in `call 
rack (2.2.6.4) lib/rack/runtime.rb:22:in `call 
activesupport (7.0.4.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/server_timing.rb:61:in `block in call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/server_timing.rb:26:in `collect_events 
actionpack (7.0.4.3) lib/action_dispatch/middleware/server_timing.rb:60:in `call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/executor.rb:14:in `call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/static.rb:23:in `call 
rack (2.2.6.4) lib/rack/sendfile.rb:110:in `call 
actionpack (7.0.4.3) lib/action_dispatch/middleware/host_authorization.rb:137:in `call 
railties (7.0.4.3) lib/rails/engine.rb:530:in `call 
puma (5.6.5) lib/puma/configuration.rb:252:in `call 
puma (5.6.5) lib/puma/request.rb:77:in `block in handle_request 
puma (5.6.5) lib/puma/thread_pool.rb:340:in `with_force_shutdown 
puma (5.6.5) lib/puma/request.rb:76:in `handle_request 
puma (5.6.5) lib/puma/server.rb:443:in `process_client 
puma (5.6.5) lib/puma/thread_pool.rb:147:in `block in spawn_thread  
问题回答

It seems yo are running your server on your own desktop computer rather than a server. Here, it appears that "something" breaks the TCP connection between your desktop and gmail s smtp gateway just after your Rails app has sent the SMTP helo command.

造成这种情况的原因往往是在你的台上或在其(公司)网络内的一些防火墙或病毒扫描器,这些扫描器否认寄出的邮件。 可能还需要通过网络的一个公司网关发出邮件。

无论如何,这似乎不是由您的来信或电子邮件造成的,而是您的网络环境或您(公司)网络的环境。

我在生产问题上有同样的问题。 你们如何解决这一问题?





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签