Created
July 25, 2017 03:12
-
-
Save dongyuwei/7a7d818857c8d3d0a48e3c983f9bebc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pony' | |
=begin | |
Use gmail's smtp server to send email: | |
1. Turn on 2-Step Verification (see https://myaccount.google.com/security) | |
2. Sign in using App Passwords (see https://support.google.com/accounts/answer/185833?hl=en) | |
or alternative method: | |
1. Turn off 2-Step Verification (see https://myaccount.google.com/security) | |
2. Allow less secure apps: https://myaccount.google.com/u/0/lesssecureapps?pli=1 | |
here we use the alternative method(Allow less secure apps, use the same login password) | |
=end | |
Pony.mail({ | |
:to => '[email protected]', | |
:subject => 'test subject', | |
:html_body => 'Allow less secure apps <div style="color:red;">hello I am sent via gmail smtp server</div>', | |
:via => :smtp, | |
:via_options => { | |
:address => 'smtp.gmail.com', | |
:port => 587, | |
:enable_starttls_auto => true, | |
:user_name => '[email protected]', | |
:password => 'the-password', | |
:authentication => :plain | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see https://support.google.com/accounts/answer/6010255?hl=en