Class: RbEAI::PutEmailLogic

Inherits:
Object
  • Object
show all
Defined in:
lib/rbeai/PutLogic.rb

Overview

<task name=“sendfile” type=“Put” rate=“0s” pool=“1”>

  <next>final</next>
  <protocol def="mail">
    <location address="" port=""/>
    <account name="" pwd=""/>
    <from></from>
    <to></to>
    <cc></cc>
    <bcc></bcc>
    <subject></subject>
  </protocol>
</task>

Instance Method Summary collapse

Constructor Details

#initialize(protNode, task) ⇒ PutEmailLogic

Returns a new instance of PutEmailLogic.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/rbeai/PutLogic.rb', line 60

def initialize(protNode, task)
  @task = task
  location  = XPath.first(protNode, "./location")
     = XPath.first(protNode, "./account")
  @address  = location.attributes["address"]
  @domain   = location.attributes["domain"]
  @port     = location.attributes["port"]
  @name     = .attributes["name"]
  @pwd      = .attributes["pwd"]    
  @from     = XPath.first(protNode, "./from/text()")
  @to       = XPath.first(protNode, "./to/text()")
  @subject  = XPath.first(protNode, "./subject/text()")
  @bodymsg  = XPath.first(protNode, "./body/text()")
  @attachment  = XPath.first(protNode, "./attachment/text()")
end

Instance Method Details

#putFile(obj) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/rbeai/PutLogic.rb', line 76

def putFile(obj)
  begin
    smtp = if @name != nil
              Net::SMTP.start(@address, @port, @domain, @name, @pwd, :login)
          elsif @domain != nil
              Net::SMTP.start(@address, @port, @domain)
          else
              Net::SMTP.start(@address, @port)
          end
    message = _buildMessage(obj)
    smtp.send_message message, "#{@from}", "#{@to}".split(",").each { |to| to.strip! }
    smtp.finish
  rescue Exception 
    puts $!
  end    
end