我無法使用我在Sinatra中建立的聯繫表單發送電子郵件。我正在使用小馬寶石。出於某種原因,我得到這個錯誤說'沒有這樣的文件存在 - 哪個sendmail'。我已經安裝了'sendmail',而且我仍然遇到同樣的問題。我願意接受任何建議。代碼如下:如何使用Pony與Sinatra一起發送郵件?
聯繫形式
<form action='/' id='contact' name='contact' method='post' novalidate='novalidate' >
<div class="form-group">
<div class="input-wrap">
<input type="text" class='form-control' name='name' id='name' placeholder='NAME'>
</div>
<br>
<div class="input-wrap">
<input type="email" class='form-control' name='mail' id='mail' placeholder='EMAIL'>
</div>
<br>
<div class="input-wrap">
<input type="text" class='form-control' name='subject' id='subject' placeholder='SUBJECT'>
</div>
<br>
<div class="input-wrap">
<textarea placeholder='MESSAGE' class='form-control' name="body" id="body" cols="30" rows="10"></textarea>
</div>
<br>
<input type='submit' value='SEND' id='button'>
</div>
</form>
main.rb的
require 'rubygems'
require 'sinatra'
require 'bundler/setup'
get '/' do
File.read('index.html')
end
post '/' do
require 'pony'
name = params[:name]
mail = params[:mail]
subject = params[:subject]
body = params[:body]
Pony.mail(:to => '[email protected]', :from => '#{name}', :subject => '#{subject}', :body => '#{body}')
# File.read('index.html')
redirect '/success'
end
get '/success' do
File.read('success.html')
end
複製並粘貼完整的錯誤消息。 '$ which sendmail'的輸出是什麼? – 7stud
Errno :: ENOENT at/ 沒有這樣的文件或目錄 - 哪個sendmail –