Skip to content

Instantly share code, notes, and snippets.

@qiukun
Created October 22, 2015 07:22
Show Gist options
  • Save qiukun/02804c71e1040fccd845 to your computer and use it in GitHub Desktop.
Save qiukun/02804c71e1040fccd845 to your computer and use it in GitHub Desktop.
用联通邮箱报警
#! /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