Sha256: 25f1d82950bd23c6de01f697fefc064015e28f135c49b64cea5f65ad1d21e6fa

Contents?: true

Size: 810 Bytes

Versions: 11

Compression:

Stored size: 810 Bytes

Contents

require 'rubygems'
require 'net/smtp'
require 'net/dns/resolver'
require 'net/dns/rr'
require 'time'

def send_mail_hardcore(recipient, recipient_name, from, from_name, subject, message)
  username, domain = recipient.split('@', 2) #yeah yeah, username can contain @ sign, will fix later

  mxrs = Net::DNS::Resolver.new.mx(domain)
  if mxrs.empty?
    puts "No MX records on domain; bad domain name"
    return
  end

  msg = <<END_OF_MESSAGE
From: #{from_name || recipient_name} <#{from || recipient}>
To: #{recipient_name} <#{recipient}>
Subject: #{subject}
Date: #{Time.now.rfc2822}
Message-Id: <#{Time.now.to_i}.#{rand(10000000)}@#{domain}>

#{message}
END_OF_MESSAGE

  Net::SMTP.start(mxrs.first.exchange, 25, domain) { |smtp| smtp.send_message msg, recipient, recipient }
end

send_mail_hardcore(*ARGV)

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bloopletech-webstats-0.1.0 clients/email_notifier/email_notifier.rb
bloopletech-webstats-0.2.0 clients/email_notifier/email_notifier.rb
bloopletech-webstats-0.2.3 clients/email_notifier/email_notifier.rb
bloopletech-webstats-0.2.4 clients/email_notifier/email_notifier.rb
bloopletech-webstats-0.3.0 clients/email_notifier/email_notifier.rb
bloopletech-webstats-0.5.0 clients/email_notifier/email_notifier.rb
bloopletech-webstats-0.6.0 clients/email_notifier/email_notifier.rb
bloopletech-webstats-0.7.0 clients/email_notifier/email_notifier.rb
bloopletech-webstats-0.8.0 clients/email_notifier/email_notifier.rb
bloopletech-webstats-0.8.1 clients/email_notifier/email_notifier.rb
bloopletech-webstats-0.9.0 clients/email_notifier/email_notifier.rb