是否可以在Ramaze这样的web框架中使用ActionMailer,或者我需要使用Rails吗?
发布于 2009-04-12 16:34:14
您可以很容易地在没有Rails的情况下使用ActionMailer。我不熟悉Ramaze,但这里有一个简单的ruby,它应该很容易集成到任何你想要的框架中:
PATH/mailer.rb
require 'rubygems'
require 'action_mailer'
class Mailer < ActionMailer::Base
def my_email
recipients "recipient@their_domain.com"
from "me@my_domain.com"
subject "my subject"
body :variable1 => 'a', :variable2 => 'b'
end
end
Mailer.template_root = File.dirname(__FILE__)
Mailer.delivery_method = :sendmail
Mailer.logger = Logger.new(STDOUT)
# this sends the email
Mailer.deliver_my_email然后将电子邮件模板放入以您的ActionMailer类命名的目录中
PATH/mailer/my_email.html.erb
variable 1: <%= @variable1 %>
variable 2: <%= @variable2 %>有关更多配置选项,请查看API Docs,但这些都是基础知识
https://stackoverflow.com/questions/741989
复制相似问题