在我看来, 您正在试图在提交表格后用电子邮件发送个人( 或多人) 。 您可以从该表格中将信息保存到数据库中 。 我认为您对如何使用 Padrino 邮件程序有些迷惑 。 允许我澄清 : 为了使用 Padrino 邮件器功能发送电子邮件, 您必须创建 Padrino Mailer (我在下面概述了此内容) 。 然后您必须配置该邮件器, 以便您在调用该邮件时将变量传递到它。 这些变量可以用于视图中, 您的邮件发送者在发送电子邮件前将它传送到电子邮件体中。 这是完成您试图完成的邮件程序的一种方式, 并且可能是最直线的前进方式 。 您可以在 < a href= > 的“ Mailler Usage” 下找到更多关于此程序的信息 。 您可以在 < a href=" http://www. padrinorb.com/ guides/padrino-mailer" rel= " nofol= " nofol " fel > hel < hel > a > hel < hel< helter < 中您在您的提问中提供什么需要.
<强度 > 指令 强度 >
I grew together this code example and tested it by my AWS account; 它应该在生产中工作。
在您的 app/app.rb
文件中,包括以下内容(你已经这样做了):
set :delivery_method, :smtp => {
:address => email-smtp.us-east-1.amazonaws.com ,
:port => 587,
:user_name => SMTP_KEY_HERE ,
:password => SMTP_SECRET_HERE ,
:authentication => :plain,
:enable_starttls_auto => true
}
然后在 app/mailers/affiliate.rb
中创建一个邮件员:
# Defines the mailer
DemoPadrinoMailer.mailer :affiliate do
# Action in the mailer that sends the email. The "do" part passes the data you included in the call from your controller to your mailer.
email :send_email do |name, email|
# The from address coinciding with the registered/authorized from address used on SES
from [email protected]
# Send the email to this person
to [email protected]
# Subject of the email
subject Affiliate email
# This passes the data you passed to the mailer into the view
locals :name => name, :email => email
# This is the view to use to redner the email, found at app/views/mailers/affiliate/send_email.erb
render affiliate/send_email
end
end
附属邮件器 s send_email
视图应位于 ap/view/mailers/affiliate/send_email.erb
中,并看起来像:
Name: <%= name %>
Email: <%= email %>
最后, 您可以从内部从任何方法( 控制器) 中调用您的邮件员, 不论您从哪个方法( 控制器) 重新接受窗体提交。 请务必用实际窗体数据替换字符串 。 在此示例中, 我使用了 POSTed < code> create code> 动作, 该动作没有保存任何数据( 因此字符串带有假数据 ):
post :create do
# Deliver the email, pass the data in after everything else; here I pass in strings instead of something that was being saved to the database
deliver(:affiliate , :send_email, "John Doe", "[email protected]")
end
我衷心希望这能帮助您与帕德里诺的旅程, 欢迎您来到Stack overflow社区!
真诚的,
罗伯特·克卢本斯皮斯(Robert Klubenspies)