1
我已经通过电子邮件为我的域设置了Google Apps安装程序,现在我需要配置ActionMailer以使用它。但我发现的信息似乎有冲突。任何人都可以告诉我如何使用Rails 2.3.5进行设置?如何使用Rails 2.3.5在ActionMailer中设置Google Apps?
我已经通过电子邮件为我的域设置了Google Apps安装程序,现在我需要配置ActionMailer以使用它。但我发现的信息似乎有冲突。任何人都可以告诉我如何使用Rails 2.3.5进行设置?如何使用Rails 2.3.5在ActionMailer中设置Google Apps?
我面临同样的问题,并得到了它与该工作:
第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)