It's information about Ruby, but it's convenient when teaching Ruby, so a procedure memo
In short, I want the following 16 digits
The following work is done on the here screen.
$ gem mail install
send_gmail.rb
require 'mail'
from = '[email protected]'
password = '16_digit_app_password'
to = '[email protected]'
Mail.defaults do
delivery_method :smtp, {
address: 'smtp.gmail.com',
port: 587,
domain: 'example.com',
user_name: from,
password: password,
authentication: :login,
enable_starttls_auto: true
}
end
m = Mail.new do
from "#{from}"
to "#{to}"
subject "Great Mail Title"
body "Fantastic body blar blar"
end
m.charset = "UTF-8"
m.content_transfer_encoding = "8bit"
m.deliver
It should work with this for the time being.
Send email via Gmail using Ruby http://1bed.allright.life/?p=2004
Recommended Posts