Created
October 22, 2015 07:22
-
-
Save qiukun/02804c71e1040fccd845 to your computer and use it in GitHub Desktop.
用联通邮箱报警
This file contains hidden or 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/ruby | |
require 'net/smtp' | |
email = '' | |
passwd = '' | |
subject = $*[0] || "Ring Ring" | |
text = $*[1] || "An alarm has been triggered." | |
message = <<MESSAGE_END | |
From: Ringer <#{email}> | |
To: You <#{email}> | |
Subject: #{subject} | |
#{text} | |
MESSAGE_END | |
# smtp = Net::SMTP.new 'smtp.wo.cn', 465 | |
# context = Net::SMTP.default_ssl_context | |
# context.verify_mode=OpenSSL::SSL::VERIFY_NONE | |
# smtp.enable_tls context | |
# smtp.set_debug_output $stderr | |
Net::SMTP.start('smtp.wo.cn', 25, 'localhost', email, passwd, :plain) do |smtp| | |
smtp.send_message message, email, email | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment