本文介绍了ActionMailer和Ramaze的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Ramaze这样的Web框架中使用ActionMailer,还是需要使用Rails?

Is it possible to use ActionMailer in a web framework like Ramaze, or do I need to use Rails?

推荐答案

您可以很容易地在没有Rails的情况下使用ActionMailer。我不熟悉Ramaze,但这是普通的红宝石,应该很容易将其集成到您希望的任何框架中:

You can use ActionMailer without Rails quite easily. I'm not familiar with Ramaze, but here's plain ruby, which should be easy to integrate into whatever framework you wish:

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类命名的目录中

Then put the email templates in a directory named after the your ActionMailer class

PATH / mailer / my_email.html.erb

variable 1: <%= @variable1 %>
variable 2: <%= @variable2 %>

查看以获取更多配置选项,但这是基础知识

Check out the API Docs for more configuration options, but those are the basics

这篇关于ActionMailer和Ramaze的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 03:55