Created
July 19, 2010 09:58
-
-
Save liuzhoou/481222 to your computer and use it in GitHub Desktop.
sendmailforgmail
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
#!/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