I am having trouble sending email using the contact form I built in Sinatra. I'm using the Pony gem. For some reason I get this error saying 'No such file exist-which sendmail'. I have installed 'sendmail' and I'm still having the same issue. I'm open to any suggestions. The code is below:
Contact form
<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 => 'mjstokes1986@att.net', :from => '#{name}', :subject => '#{subject}', :body => '#{body}')
# File.read('index.html')
redirect '/success'
end
get '/success' do
File.read('success.html')
end
Try to tell Pony.mail
method where to find your sendmail
. You can find your sendmail location using which sendmail
. (If this doesn't return anything then you just haven't installed the sendmail correctly).
Pony.mail({
...
:via_options => { :location => '/path/to/your/sendmail'}
})