If you ever need to send emails from ruby, use the mail gem. Run
gem install mail
to install the gem. Here’s how to send an UTF-8 encoded multipart mail via SMTP and TLS.
require 'mail'
m = Mail.new do
delivery_method :smtp, {
:address => 'smtp.mydomain.com',
:domain => 'mydomain.com',
:user_name => 'smtp_login',
:password => 'smtp_password',
:enable_starttls_auto => true,
:authentication => :plain,
}
from 'me@mydomain.com'
to 'you@yourdomain.com'
subject 'Testing, 1, 2, 3!'
text_part do
content_type 'text/plain; charset=UTF-8'
body 'Hi there!'
end
html_part do
content_type 'text/html; charset=UTF-8'
body '<html><body><h1>Hi there!</h1></body></html>'
end
end
m.deliver