无法通过Pony和Ruby Sinatra发送邮件,获得"文件结束"错误

时间:2016-07-10 17:15:23

标签: ruby email sinatra eof pony

我正在尝试通过Pony发送邮件,出于某种原因这个"文件结束"错误显示.........

EOFError at /contact-us
end of file reached
file: buffering.rb location: sysread_nonblock line: 182

以下是设置:

require 'sinatra'
require 'rubygems'
require 'bundler/setup'

set :views, File.dirname(__FILE__) + '/views'
set :public_folder, File.dirname(__FILE__) + '/public'


get '/' do 
    erb :index
end

get '/overview' do
    erb :overview
end

get '/our-mission' do
    erb :mission
end

get '/customers' do
    erb :customers
end

get '/retail-support' do
    erb :retail
end

get '/contact-us' do
    erb :contact
end

post '/contact-us' do
    require 'pony'
    first_name  = params[:first_name]
    last_name = params[:last_name]
    mail = params[:mail]
    subject = params[:subject]
    body  = params[:body]

Pony.mail({
    :to => 'merchandising@nlm-marketing.com',
    :from => first_name + '<' + mail + '>',
    :reply_to => mail,
    :subject => subject,
    :body => body, 
    :via => :smtp,
    :via_options => {
        :address => 'smtp.zoho.com',
        :port => 465,
        :user_name => 'username',
        :password => 'password',
        :authentication => :login,
        :ssl => true,
        :tls => true,
        :enable_starttls_auto => true

    }
    })



    redirect '/success'
end

get '/success' do 
    erb :success
end

这是回溯:

c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/openssl/buffering.rb in sysread_nonblock
      return sysread_nonblock(maxlen, buf, exception: exception)
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/openssl/buffering.rb in read_nonblock
      return sysread_nonblock(maxlen, buf, exception: exception)
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/net/protocol.rb in rbuf_fill
        @rbuf << @io.read_nonblock(BUFSIZE)
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/net/protocol.rb in readuntil
          rbuf_fill
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/net/protocol.rb in readline
      readuntil("\n").chop
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/net/smtp.rb in recv_response
        line = @socket.readline
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/net/smtp.rb in block in getok
        recv_response()
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/net/smtp.rb in critical
        return yield()
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/net/smtp.rb in getok
      res = critical {
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/net/smtp.rb in quit
      getok('QUIT')
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/net/smtp.rb in do_finish
      quit if @socket and not @socket.closed? and not @error_occurred
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/net/smtp.rb in ensure in start
          do_finish
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/net/smtp.rb in start
          do_finish
main.rb in block in <main>
Pony.mail({
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb in service
      si.service(req, res)
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb in run
          server.service(req, res)
c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/webrick/server.rb in block in start_thread
          block ? block.call(sock) : run(sock)

我不知道为什么我收到错误。发生了什么,我该怎么做才能解决它?

0 个答案:

没有答案