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