2010-10-12 67 views

回答

1

我面临同样的问题,并得到了它与该工作:

第1步:添加以下到您的开发环境:

ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.perform_deliveries = true 
ActionMailer::Base.raise_delivery_errors = true 
ActionMailer::Base.default_charset = "utf-8" 
ActionMailer::Base.smtp_settings = { 
    :enable_starttls_auto => true, 
    :address   => "smtp.gmail.com", 
    :port    => "587", 
    :domain    => "domain.com", 
    :authentication  => :plain, 
    :user_name   => "YOUR_USER_NAME", #should be [email protected] 
    :password   => "YOUR_PASSWORD_HERE" 
} 

的临界线为:enable_starttls_auto。在进行更改后,您必须重新启动webrick。

步骤2.创建模型等project_mailer.rb

class ProjectMailer < ActionMailer::Base 

    def confirmation(project) 
    subject 'Your email subject' 
    recipients project.email 
    from  '[email protected]' 

    body  :project => "hi" 
    end 
end 

步骤3.创建像一个/views/project_mailer/confirmation.html.haml视图(或.erb)。这只是一个标准的视图文件。

第4步:添加一行在你的控制器,如:

ProjectMailer.deliver_confirmation(@project) 
相关问题