看了python 和 ruby 的 一些库,仿了一个 ruby 的 smtptls,当然只是个雏形,加入方法的块就更好了
使用方法:
#Example:
require 'SMTPTLS'
host = 'smtp.gmail.com'
port = 25
user = 'vkill.net@gmail.com'
secret = '*******'
to = []
to << '122755990@qq.com'
to << 'vkill.net@hotmail.com'
msgstr = <<-MSGEND
From: "vkill.net" <vkill.net@gmail.com>
To: 122755990@qq.com
Subject: test,sendmail
Date: Thu, 16 Jul 2009 18:35:03 +0800
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="===ruby-vkmailsend[0.3919741430011]==="
X-mailer: ruby-vkmailsend [cn]
--===ruby-vkmailsend[0.3919741430011]===
Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: base64
dGVzdA==
--===ruby-vkmailsend[0.3919741430011]===--
MSGEND
begin
smtp = SMTPTLS.new()
smtp.set_debug_output
#smtp.enable_ssl()
smtp.start(host, 25, user, secret)
smtp.send_message(msgstr, user, to) #smtp.send_message(msgstr, user) ##send mail to me
puts "send mail ok!" if smtp.state
rescue
if $!.message =~ /\[([^\]]+)\]/
printf "ERR->[%s]\n", $1
else
printf "ERR->[%s]\n", $!.message
end
end
smtptls 库下载:
Download
Last modified by vkill on2009/08/07 16:57
使用方法:
#Example:
require 'SMTPTLS'
host = 'smtp.gmail.com'
port = 25
user = 'vkill.net@gmail.com'
secret = '*******'
to = []
to << '122755990@qq.com'
to << 'vkill.net@hotmail.com'
msgstr = <<-MSGEND
From: "vkill.net" <vkill.net@gmail.com>
To: 122755990@qq.com
Subject: test,sendmail
Date: Thu, 16 Jul 2009 18:35:03 +0800
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="===ruby-vkmailsend[0.3919741430011]==="
X-mailer: ruby-vkmailsend [cn]
--===ruby-vkmailsend[0.3919741430011]===
Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: base64
dGVzdA==
--===ruby-vkmailsend[0.3919741430011]===--
MSGEND
begin
smtp = SMTPTLS.new()
smtp.set_debug_output
#smtp.enable_ssl()
smtp.start(host, 25, user, secret)
smtp.send_message(msgstr, user, to) #smtp.send_message(msgstr, user) ##send mail to me
puts "send mail ok!" if smtp.state
rescue
if $!.message =~ /\[([^\]]+)\]/
printf "ERR->[%s]\n", $1
else
printf "ERR->[%s]\n", $!.message
end
end
smtptls 库下载:
Download Last modified by vkill on2009/08/07 16:57
网友评论(0):


