It is very easy to use Ruby to get the page content. I checked the information and tried to write an email sending code. It seems that Ruby is used to implement "Java calls jruby to get webpage content (jdk1.5) "The requirement in this article is more convenient. The Code is as follows:
Require 'net/http'
Require 'uri'
Require "net/SMTP"
STR = net: http. Get (URI. parse ('HTTP: // www.google.cn '));
# Puts Str
Def sendemail (subject, content, to = nil)
From = "Youremail@163.com"
To = ["xxx@qq.com", "xxx2@qq.com"] If to. nil?
Sendmessage = "Subject:" + Subject + "/n" + content
# Parameter description: 'Your. SMTP. Server', 25, 'mail. From. Domain ', 'Your account', 'Your password', authtype
SMTP = net: SMTP. Start ('smtp .163.com ', 25, '2017. com', Youremail@163.com', 'xxxxx',: Login)
SMTP. send_message sendmessage, from,
SMTP. Finish
End
Sendemail ("test", STR, nil)
Puts ("-- send OK ----");
SMTP supports three authentication parameters:
1): Plain
2): Login
3): cram_md5
Is it concise? ^-^