ActionMailer 和 Ramaze

发布于 2024-07-17 12:38:00 字数 60 浏览 3 评论 0原文

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

很酷又爱笑 2024-07-24 12:38:00

您可以在没有 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 文档 了解更多配置选项,但这些是基础知识

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文