tlsmail_ext 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/tlsmail.rb ADDED
@@ -0,0 +1,30 @@
1
+ require "net/smtp"
2
+ require "net/pop"
3
+ # If smtp or pop is already loaded, remove all constants.
4
+ module Net
5
+ if defined?(SMTP)
6
+ SMTP.class_eval do remove_const(:Revision) end
7
+ [:SMTP, :SMTPSession].each do |c|
8
+ remove_const(c) if constants.include?(c.to_s)
9
+ end
10
+ end
11
+ if defined?(POP)
12
+ POP.class_eval do remove_const(:Revision) end
13
+ [:POP, :POPSession, :POP3Session, :APOPSession].each do |c|
14
+ remove_const(c) if constants.include?(c.to_s)
15
+ end
16
+ end
17
+ end
18
+
19
+ load File.dirname(__FILE__) + "/net/smtp.rb"
20
+ load File.dirname(__FILE__) + "/net/pop.rb"
21
+
22
+ Net::SMTP.class_eval do
23
+ def quit # gmail smtp server disconnects as soon as get quit message.
24
+ begin
25
+ getok('QUIT')
26
+ rescue EOFError
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,10 @@
1
+ # This file is a template for parameters.rb
2
+ # Copy this file and change variables below.
3
+ SMTP_SERVER = "smtp.gmail.com"
4
+ SMTP_PORT = "587"
5
+ POP_SERVER = "pop.gmail.com"
6
+ POP_PORT = "995"
7
+ DOMAIN = "localhost.localdomain"
8
+ AUTH = :plain
9
+ USER = "XXXXXXXXXXXX@gmail.com"
10
+ PASS = "ZZZZZZZZZZ"
@@ -0,0 +1,4 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/tlsmail'
4
+ require "parameters"
@@ -0,0 +1,34 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TlsmailTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+
12
+ def test_send_mail
13
+ require "time"
14
+ msgstr = <<END_OF_MESSAGE
15
+ From: Your Name <#{USER}@gmail.com>
16
+ To: Destination Address <#{USER}@gmail.com>
17
+ Subject: test message
18
+ Date: #{Time.now.rfc2822}
19
+
20
+ test message.
21
+ END_OF_MESSAGE
22
+ Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
23
+ Net::SMTP.start(SMTP_SERVER, SMTP_PORT, DOMAIN, USER, PASS, AUTH) do |smtp|
24
+ smtp.send_message msgstr, "#{USER}@gmail.com", "#{USER}@gmail.com"
25
+ end
26
+ end
27
+
28
+ def test_receive_mail
29
+ Net::POP.enable_ssl(OpenSSL::SSL::VERIFY_NONE)
30
+ Net::POP.start(POP_SERVER, POP_PORT, USER, PASS) do |pop|
31
+ p pop.mails[0].pop
32
+ end
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tlsmail_ext
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - debbbbie
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-08-09 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: This library is forked from tlsmail,just remove deperated warnings!
22
+ email: debbbbie@163.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - Rakefile
31
+ - README.txt
32
+ - CHANGELOG.txt
33
+ - Manifest.txt
34
+ - lib/tlsmail.rb
35
+ - lib/net/pop.rb
36
+ - lib/net/smtp.rb
37
+ - test/test_helper.rb
38
+ - test/tlsmail_test.rb
39
+ - test/template.parameters.rb
40
+ homepage: https://github.com/debbbbie/tlsmail
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">"
52
+ - !ruby/object:Gem::Version
53
+ hash: 31
54
+ segments:
55
+ - 0
56
+ - 0
57
+ - 0
58
+ version: 0.0.0
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project: tlsmail_ext
71
+ rubygems_version: 1.8.24
72
+ signing_key:
73
+ specification_version: 1
74
+ summary: This library enables pop or smtp via ssl/tls by dynamically replacing these classes to these in ruby 1.9.
75
+ test_files:
76
+ - test/tlsmail_test.rb