English 中文(简体)
如何让Amazon SES在提交 Padrino 表格后发送?
原标题:How do you get Amazon SES to send upon submission of form in Padrino
  • 时间:2012-05-23 14:42:55
  •  标签:
  • html
  • padrino

遵循以下指示:http://www.padrinorb.com/guides/padrino-mailer

我在App.rb文件上添加了传送方法:

class OscarAffiliate < Padrino::Application
  register Padrino::Rendering
  register Padrino::Mailer
  register Padrino::Helpers

  enable :sessions

  set :delivery_method, :smtp => { 
    :address              => "email-smtp.us-east-1.amazonaws.com",
    :port                 => 587,
    :user_name            =>  AKIAIQ5YXCWFKFXFFRZA ,
    :password             =>  AqMNMFecKSYR/TRu8kJgocysAL5SmIUsu2i8u/KAfeF/ ,
    :authentication       => :plain,
    :enable_starttls_auto => true  
  }

但透过帕德里诺和梅勒一代的一代人, 我没有推荐的“会议”控制器,

post :create do
  email(:from => "[email protected]", :to => "[email protected]", :subject => "Welcome!",     :body=>"Body")
end

我漏掉了什么吗?

我有一份办公室基本数据收集表,只需要发电子邮件给5个收件者,其中含有信息体中的所有表单字段。

谢谢 谢谢

最佳回答

在我看来, 您正在试图在提交表格后用电子邮件发送个人( 或多人) 。 您可以从该表格中将信息保存到数据库中 。 我认为您对如何使用 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 动作, 该动作没有保存任何数据( 因此字符串带有假数据 ):

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)

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签