scmuser created the topic: A simple Ruby method to send email
A simple Ruby method to send email
[code language=”css”]
require ‘net/smtp’
def send_email(to,opts={})
opts[:server] ||= ‘localhost’
opts[:from] ||= ’email@example.com’
opts[:from_alias] ||= ‘Example Emailer’
opts[:subject] ||= “You need to see this”
opts[:body] ||= “Important stuff!”
msg = <<END_OF_MESSAGE
From: #{opts[:from_alias]} <#{opts[:from]}>
To: <#{to}>
Subject: #{opts[:subject]}
#{opts[:body]}
END_OF_MESSAGE
Net::SMTP.start(opts[:server]) do |smtp|
smtp.send_message msg, opts[:from], to
end
end
[/code]
send_email “admnistrator@example.com”, :body => “This was easy to send”
Source – jerodsanto.net/2009/02/a-simple-ruby-method-to-send-email/
- Installing Jupyter: Get up and running on your computer - November 2, 2024
- An Introduction of SymOps by SymOps.com - October 30, 2024
- Introduction to System Operations (SymOps) - October 30, 2024