Method: Ruote::SmtpParticipant#consume

Defined in:
lib/ruote/part/smtp_participant.rb

#consume(workitem) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/ruote/part/smtp_participant.rb', line 88

def consume(workitem)

  to = workitem.fields['email_target'] || @opts['to']
  to = Array(to)

  text = render_template(
    @opts['template'],
    Ruote::Exp::FlowExpression.fetch(@context, workitem.fei.to_h),
    workitem)

  server = @opts['server'] || '127.0.0.1'
  port = @opts['port'] || 25

  Net::SMTP.start(server, port) do |smtp|
    smtp.send_message(text, @opts['from'] || '[email protected]', *to)
  end

  reply_to_engine(workitem) if @opts['notification']
end