Skip to content

Instantly share code, notes, and snippets.

@liuzhoou
Created July 19, 2010 09:58
Show Gist options
  • Save liuzhoou/481222 to your computer and use it in GitHub Desktop.
Save liuzhoou/481222 to your computer and use it in GitHub Desktop.
sendmailforgmail
#!/usr/bin/env ruby
#use Unicode
$KCODE = 'u'
require 'jcode'
require 'rubygems'
require 'action_mailer'
require 'tlsmail' #need install tlsmail gem to support TLS connect
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
ActionMailer::Base.smtp_settings = {
:address => 'smtp.gmail.com', #default: localhost
:port => '25', #default: 25
:user_name => '[email protected]',#login name
:password => 'xxx', #login password
:authentication => :login #:plain, :login or :cram_md5
}
class SimpleMailer < ActionMailer::Base
def simple_message(recipient, mail_subject, mail_body)
from '[email protected]'
recipients recipient
subject mail_subject
body mail_body
end
end
msg = ARGV[0]
SimpleMailer.deliver_simple_message '[email protected]', 'ruby - SystemMessage', msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment