Send email using Net::SMTP under Ruby

# smtp.rb
 
require 'net/smtp'
require 'pp'
 
smtp = Net::SMTP.new('mail.mnain.org')
#p smtp
smtp.start('madan@mnain.org')
msg = "Subject: Test\r\n" +
                "From: Madan Nain <madan@mnain.org>\r\n" +
                "\r\n" +
                "This is a test message " +
                " from Madan to madan@mnain.org " +
                "\r\n" +
                " testing smtp using ruby " +
                "Second line of msg " +
                "\r\n"
puts msg
 
#p smtp
smtp.sendmail(msg, 'madan@mnain.org','learn@mnain.org')

rubysmtp.txt · Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0