41 lines
1.1 KiB
Ruby
41 lines
1.1 KiB
Ruby
require "mail"
|
|
|
|
class ReadingsMailer
|
|
OPTS = { :address => "mail.van-halteren.net",
|
|
:port => 465,
|
|
:domain => 'van-halteren.net',
|
|
:user_name => 'aart@van-halteren.net',
|
|
:password => '',
|
|
:authentication => 'plain',
|
|
:enable_ssl => true}
|
|
|
|
OPTS_NO_SSL_VERIFY = {
|
|
:openssl_verify_mode => OpenSSL::SSL::VERIFY_NONE,
|
|
}
|
|
|
|
#
|
|
# Class methods
|
|
#
|
|
class << self
|
|
def deliver
|
|
|
|
mail = Mail.new do
|
|
delivery_method :smtp, OPTS_NO_SSL_VERIFY
|
|
to 'aart@van-halteren.net'
|
|
from 'SmartMeter <aart@van-halteren.net>'
|
|
subject 'First multipart email sent with Mail'
|
|
|
|
text_part do
|
|
body 'This is plain text'
|
|
end
|
|
|
|
html_part do
|
|
content_type 'text/html; charset=UTF-8'
|
|
body '<h1>This is HTML</h1>'
|
|
end
|
|
end
|
|
|
|
mail.deliver!
|
|
end
|
|
end
|
|
end |