daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest May 22nd, 2018 251 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # encoding: euc-jp
  2. require "rubygems"
  3. require "tlsmail"
  4. require "net/smtp"
  5.  
  6. def sendgmail(from, to, subject, body, user = "your Gmail account", pass = "your Gmail pass", host = "smtp.gmail.com", port = 587)
  7.   body = <<EOT
  8. From: #{from}
  9. To: #{to}
  10. Subject: #{subject}
  11. Date: #{Time::now.strftime("%a, %d %b %Y %X %z")}
  12. Mime-Version: 1.0
  13. Content-Type: text/plain; charset=EUC-JP
  14. Content-Transfer-Encoding: 7bit
  15.  
  16. #{body}
  17. EOT
  18.  
  19. Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
  20. Net::SMTP.start(host, port, "localhost.localdomain", user, pass, "plain") do |smtp|
  21.         smtp.send_mail body, from, to
  22.           end
  23. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top