Ruby on rails问题与邮件程序

时间:2014-01-31 00:02:13

标签: ruby-on-rails actionmailer

你好我是ruby on rails的新手,我正在尝试实现一个电子邮件发件人。我希望电子邮件发件人每次有人输入电子邮件时都会发送电子邮件。但由于某种原因不起作用,请帮助我。

 class ZipMailer < ActionMailer::Base
    default from: "Example@gmail.com"
    def zip_email_confirmation(zip_mailer)
       recipents zip_mailer
       from    "Example@gmail.com"
       subject "Thanks from Example"
       body     :zip_mailer => zip_mailer
    end
 end              

ActionMailer::Base.smtp_settings = {
    :address              =>"smtp.gmail.com",
    :port                 =>587,
    :domain               =>"gmail.com",
    :user_name            =>"gmail",
    :password             =>"12345",
    :authentication       =>"plain",
    :enable_starttls_auto => true
}





 def create
    @box = Box.new(box_params)
    #TO DO: validations. return errors or save
    if @box.save
       ZipMailer.zip_email_confirmation(@zip_mailer).deliver
       ConfirmMailer.box_alert(@box).deliver
       session[:box_id] = @box.id
       render 'charges/new'

    else
      render action: 'new'
    end   



<%= form_tag do %>
<%= email_field(:zip_mailer, :address) %>

 <%= submit_tag("sub") %>
<% end %>

0 个答案:

没有答案