Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals

A simple Ruby method to send email

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/

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x