Created
July 29, 2010 03:59
-
-
Save rtanglao/497195 to your computer and use it in GitHub Desktop.
sendmail.rb
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
from_address = from_you@gmail.com | |
to_address = to_somebody@gmail.com | |
p = 'yourgmailpassword' |
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 'tlsmail' | |
require 'time' | |
require 'parseconfig' | |
email_config = ParseConfig.new('email.conf').params | |
from = email_config['from_address'] | |
to = email_config['to_address'] | |
p = email_config['p'] | |
content = <<EOF | |
From: #{from} | |
To: #{to} | |
subject: TEST from ruby | |
Date: #{Time.now.rfc2822} | |
how are you roland | |
EOF | |
print 'content', content | |
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) | |
Net::SMTP.start('smtp.gmail.com', 587, 'gmail.com', from, p, :login) do |smtp| | |
smtp.send_message(content, from, to) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment