Send Gmail From Ruby Script


Now we are going to see , how to send e-mail from Ruby Script.

fro that we need to install ,

$ sudo apt-get install ruby

$ sudo apt-get install rubygems

$ sudo gem install tlsmail


require ‘rubygems’
require ‘tlsmail’
require ‘time’

$a.each do |to_mail|

content = <<MESSAGE_END
From: Arulalan <>
To: #{to_mail}
Subject: SMTP e-mail test

This is a test e-mail message….

hi da.. how r u .. i m fine… now i sending this mail from ruby scrpt…… This body of our mail


Net::SMTP.start(‘’, 587, ‘’, ‘’, ‘my passwd’, :login) do |smtp|
smtp.send_message(content, ‘’, “#{to_mail}”)


# End Of Program

in this Prog , $a is an array and u can add many email id  to send mail.

and in this program tarulalan@gmail is my mail id.. you can replace with ur  gmail id.  🙂

அருளாளன் . த


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: