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