Class: OpenWFE::EmailNotificationParticipant
- Inherits:
-
MailParticipant
- Object
- MailParticipant
- OpenWFE::EmailNotificationParticipant
- Defined in:
- lib/openwfe/participants/enoparticipants.rb
Overview
This participant is used to send an email notification.
It’s perhaps better to use MailParticipant which is simpler to initialize. This class is anyway an extension of MailParticipant.
@engine.register_participant(
'eno',
EmailNotificationParticipant.new(
"googlemail.l.google.com",
25,
"[email protected]",
"""Subject: test 0
0 : ${r:Time.new}
1 : ${f:customer_name}
"""))
And then, from the process definition :
class TestDefinition0 < OpenWFE::ProcessDefinition
def make
process_definition :name => "test0", :revision => "0" do
sequence do
set :field => 'email_target' do
"[email protected]"
end
set :field => 'customer_name' do
"Monsieur Toto"
end
participant :ref => 'eno'
end
end
end
end
The ‘template’ parameter may contain an instance of File instead of an instance of String.
@engine.register_participant(
'eno',
EmailNotificationParticipant.new(
"googlemail.l.google.com",
25,
"[email protected]",
File.new("path/to/my/mail/template.txt")))
You can also define the email template as a Ruby block :
p = EmailNotificationParticipant.new("googlemail.l.google.com", 25, "[email protected]") do | flowexpression, participant, workitem |
# generally, only the workitem is used within a template
s = ""
# the header of the message
s << "Subject: #{workitem.subject}\n\n"
# then, the body
workitem.attributes.each do |key, value|
s << "- '#{k}' => '#{value}'\n"
end
s << "\ndone.\n"
end
Note that the template integrates the subject and requires then a double newline before the message body.
Instance Attribute Summary
Attributes included from Contextual
Instance Method Summary collapse
-
#initialize(smtp_server, smtp_port, from_address, template = nil, &block) ⇒ EmailNotificationParticipant
constructor
Create a new email notification participant.
Methods inherited from MailParticipant
Methods included from TemplateMixin
Methods included from LocalParticipant
#call_block, #get_flow_expression, #reply_to_engine
Methods included from Participant
Methods included from Contextual
#get_work_directory, #init_service, #lookup
Methods included from Logging
#ldebug, #ldebug_callstack, #lerror, #lfatal, #linfo, #llog, #lunknown, #lwarn
Methods included from OwfeServiceLocator
#get_engine, #get_error_journal, #get_expool, #get_expression_map, #get_expression_pool, #get_expression_storage, #get_expression_storages, #get_journal, #get_participant_map, #get_scheduler, #get_wfid_generator
Constructor Details
#initialize(smtp_server, smtp_port, from_address, template = nil, &block) ⇒ EmailNotificationParticipant
Create a new email notification participant. Requires a mail server, port, a from address, and a mail message template
217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/openwfe/participants/enoparticipants.rb', line 217 def initialize ( smtp_server, smtp_port, from_address, template=nil, &block) params = {} params[:smtp_server] = smtp_server params[:smtp_port] = smtp_port params[:from_address] = from_address params[:template] = template if template super(params, &block) end |