3
我正在尝试为Redmine创建一个消息插件。我对此有几点质疑Redmine插件开发
我该如何在Redmine插件中发送电子邮件? 是否可以在插件内部创建邮件程序?如果是的话 创建邮件的命令是什么?
我能够看到这个(call_hook)方法几乎所有的 控制器中的文件。这种方法的用途是什么?
由于提前
我正在尝试为Redmine创建一个消息插件。我对此有几点质疑Redmine插件开发
我该如何在Redmine插件中发送电子邮件? 是否可以在插件内部创建邮件程序?如果是的话 创建邮件的命令是什么?
我能够看到这个(call_hook)方法几乎所有的 控制器中的文件。这种方法的用途是什么?
由于提前
有两种方法如何做到这一点:
我在插件01中使用了第二个,你可以下载它,并在LIB/redmine_contacts /补丁/ mailer_patch.rb
require 'dispatcher'
module RedmineContacts
module Patches
module MailerPatch
module InstanceMethods
def contacts_note_added(note, parent)
redmine_headers 'X-Project' => note.source.project.identifier,
'X-Notable-Id' => note.source.id,
'X-Note-Id' => note.id
message_id note
if parent
recipients (note.source.watcher_recipients + parent.watcher_recipients).uniq
else
recipients note.source.watcher_recipients
end
subject "[#{note.source.project.name}] - #{parent.name + ' - ' if parent}#{l(:label_note_for)} #{note.source.name}"
body :note => note,
:note_url => url_for(:controller => 'notes', :action => 'show', :note_id => note.id)
render_multipart('note_added', body)
end
def contacts_issue_connected(issue, contact)
redmine_headers 'X-Project' => contact.project.identifier,
'X-Issue-Id' => issue.id,
'X-Contact-Id' => contact.id
message_id contact
recipients contact.watcher_recipients
subject "[#{contact.projects.first.name}] - #{l(:label_issue_for)} #{contact.name}"
body :contact => contact,
:issue => issue,
:contact_url => url_for(:controller => contact.class.name.pluralize.downcase, :action => 'show', :project_id => contact.project, :id => contact.id),
:issue_url => url_for(:controller => "issues", :action => "show", :id => issue)
render_multipart('issue_connected', body)
end
end
def self.included(receiver)
receiver.send :include, InstanceMethods
receiver.class_eval do
unloadable
self.instance_variable_get("@inheritable_attributes")[:view_paths] << RAILS_ROOT + "/vendor/plugins/redmine_contacts/app/views"
end
end
end
end
end
Dispatcher.to_prepare do
unless Mailer.included_modules.include?(RedmineContacts::Patches::MailerPatch)
Mailer.send(:include, RedmineContacts::Patches::MailerPatch)
end
end
我曾尝试使用以下命令创建邮件检查,但它不工作“Ruby脚本/生成redmine_plugin_mailer通信通知”,我得到以下错误“无法找到'redmine_plugin_mailer'生成器' – 2012-04-30 07:41:41
只需在模型文件夹yourplugin_mailer.rb中创建新文件。这些不是邮件的插件生成器 – 2012-05-03 05:59:58