Guest User

Untitled

a guest
May 22nd, 2018
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment