Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'net/smtp'
- def send_email (to:, msg:, subject:, from_name:, from:, password:)
- message = "From: #{from_name} <#{from}>\n" \
- "To: <#{to}>\n"\
- "Subject: #{subject}\n"\
- "#{msg}\n"
- smtp = Net::SMTP.new 'smtp.gmail.com', 587
- smtp.enable_starttls
- smtp.start('gmail.com',
- from,
- password,
- :plain) do |smtp|
- smtp.send_message message, from, to
- end
- end
- # ex:
- send_email to: 'trump@whitehouse.gov',
- from: 'joe@gmail.com',
- subject: 'lol',
- from_name: 'Joe Blow',
- password: 'badpassword',
- msg: 'lol'
Add Comment
Please, Sign In to add comment