Skip to content

Instantly share code, notes, and snippets.

@rtanglao
Created July 29, 2010 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rtanglao/497195 to your computer and use it in GitHub Desktop.
Save rtanglao/497195 to your computer and use it in GitHub Desktop.
sendmail.rb
from_address = from_you@gmail.com
to_address = to_somebody@gmail.com
p = 'yourgmailpassword'
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