我正在尝试使用 sinatra 中的 Pony Gem 从联系表单(内置 HTML)发送电子邮件,我已按照文档进行操作,但必须缺少某些内容。
这是小马配置
get '/contact' do
erb :contact, :layout => :layout
end
post '/contact' do
require 'pony'
Pony.mail({
:from => params[:name],
:to => 'myemailaddress',
:subject => params[:name] + "has contacted you via the Website",
:body => params[:comment],
:via => :smtp,
:via_options => {
:address => 'smtp.gmail.com',
:port => '587',
:enable_starttls_auto => true,
:user_name => 'myemailaddress',
:password => 'mypassword',
:authentication => :plain,
:domain => "localhost.localdomain"
}
})
redirect '/success'
end
get('/success') do
@notification = "Thanks for your email. I'll be in touch soon."
erb :index, :layout => :layout
end
所以点击提交后,联系页面会重新呈现,没有任何消息
这是我的提交按钮
<button type="submit" class="btn" value="send">Submit</button>
我在某处错过了触发器吗?