Module: Rhcf::Utils::Email
- Defined in:
- lib/rhcf/utils/email.rb
Class Method Summary collapse
- .get_mxs(domain) ⇒ Object
- .transmit(from, to, body, bind_interface, ehlo = 'localhost.localdomain') ⇒ Object
Class Method Details
.get_mxs(domain) ⇒ Object
30 31 32 33 34 |
# File 'lib/rhcf/utils/email.rb', line 30 def self.get_mxs(domain) Resolv::DNS.open do |dns| dns.getresources(domain, Resolv::DNS::Resource::IN::MX).collect{|x| x.exchange.to_s} end end |
.transmit(from, to, body, bind_interface, ehlo = 'localhost.localdomain') ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rhcf/utils/email.rb', line 36 def self.transmit(from, to, body, bind_interface, ehlo = 'localhost.localdomain') domain = to.split('@').last chat = StringIO.new mx = get_mxs(domain).sample smtp = Net::SMTP.new(mx, 25) smtp.bind_at bind_interface result = smtp.start(ehlo) do |smtp| smtp.socket.debug_output = chat smtp. body, from, to end {status: result.status, string: result.string, chat: chat.string} end |