Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # encoding: euc-jp
- require "rubygems"
- require "tlsmail"
- require "net/smtp"
- def sendgmail(from, to, subject, body, user = "your Gmail account", pass = "your Gmail pass", host = "smtp.gmail.com", port = 587)
- body = <<EOT
- From: #{from}
- To: #{to}
- Subject: #{subject}
- Date: #{Time::now.strftime("%a, %d %b %Y %X %z")}
- Mime-Version: 1.0
- Content-Type: text/plain; charset=EUC-JP
- Content-Transfer-Encoding: 7bit
- #{body}
- EOT
- Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
- Net::SMTP.start(host, port, "localhost.localdomain", user, pass, "plain") do |smtp|
- smtp.send_mail body, from, to
- end
- end
Add Comment
Please, Sign In to add comment