Skip to content

Instantly share code, notes, and snippets.

@dpwright
Created April 16, 2012 00:57
Show Gist options
  • Select an option

  • Save dpwright/2395670 to your computer and use it in GitHub Desktop.

Select an option

Save dpwright/2395670 to your computer and use it in GitHub Desktop.
Sending email with Ruby + Google Apps Mail
#!/usr/bin/env ruby
require 'rubygems'
require 'tlsmail'
msg=<<EOF
From: Test Sender <sender@domain.com>
To: Test Recipient <recipient@domain.com>
Subject: test
This is a test
EOF
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
Net::SMTP.start('smtp.gmail.com', 587, 'domain.com', 'sender@domain.com', 'password', :login) do |smtp|
smtp.send_message msg, "sender@domain.com", "recipient@domain.com"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment