HomeScriptsRuby script for sending mail

Ruby script for sending mail

Ever wanted to send emails using the ruby script? Use the one below :

require 'net/smtp'
puts "Enter the from address:"
_from = gets.chomp
puts "Enter the to address:"
_to = gets.chomp
puts "Please type the mail content"
_content = gets.chomp
begin
  Net::SMTP.start('localhost', 25) do |mail|
    mail.send_message(_content, _from, _to)
end
end

Note: You need ruby installed on the server.

Scroll to Top