lonbaker-tmail 1.2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. data/CHANGES +74 -0
  2. data/LICENSE +21 -0
  3. data/NOTES +7 -0
  4. data/README +169 -0
  5. data/ext/Makefile +20 -0
  6. data/ext/tmailscanner/tmail/MANIFEST +4 -0
  7. data/ext/tmailscanner/tmail/depend +1 -0
  8. data/ext/tmailscanner/tmail/extconf.rb +33 -0
  9. data/ext/tmailscanner/tmail/tmailscanner.c +583 -0
  10. data/lib/tmail.rb +5 -0
  11. data/lib/tmail/Makefile +18 -0
  12. data/lib/tmail/address.rb +426 -0
  13. data/lib/tmail/attachments.rb +46 -0
  14. data/lib/tmail/base64.rb +46 -0
  15. data/lib/tmail/compat.rb +41 -0
  16. data/lib/tmail/config.rb +67 -0
  17. data/lib/tmail/core_extensions.rb +63 -0
  18. data/lib/tmail/encode.rb +590 -0
  19. data/lib/tmail/header.rb +962 -0
  20. data/lib/tmail/index.rb +9 -0
  21. data/lib/tmail/interface.rb +1130 -0
  22. data/lib/tmail/loader.rb +3 -0
  23. data/lib/tmail/mail.rb +580 -0
  24. data/lib/tmail/mailbox.rb +496 -0
  25. data/lib/tmail/main.rb +6 -0
  26. data/lib/tmail/mbox.rb +3 -0
  27. data/lib/tmail/net.rb +248 -0
  28. data/lib/tmail/obsolete.rb +132 -0
  29. data/lib/tmail/parser.rb +1476 -0
  30. data/lib/tmail/parser.y +381 -0
  31. data/lib/tmail/port.rb +379 -0
  32. data/lib/tmail/quoting.rb +118 -0
  33. data/lib/tmail/require_arch.rb +58 -0
  34. data/lib/tmail/scanner.rb +49 -0
  35. data/lib/tmail/scanner_r.rb +261 -0
  36. data/lib/tmail/stringio.rb +280 -0
  37. data/lib/tmail/utils.rb +351 -0
  38. data/lib/tmail/version.rb +39 -0
  39. data/meta/MANIFEST +128 -0
  40. data/meta/project.yaml +30 -0
  41. data/meta/unixname +1 -0
  42. data/sample/bench_base64.rb +48 -0
  43. data/sample/data/multipart +23 -0
  44. data/sample/data/normal +29 -0
  45. data/sample/data/sendtest +5 -0
  46. data/sample/data/simple +14 -0
  47. data/sample/data/test +27 -0
  48. data/sample/extract-attachements.rb +33 -0
  49. data/sample/from-check.rb +26 -0
  50. data/sample/multipart.rb +26 -0
  51. data/sample/parse-bench.rb +68 -0
  52. data/sample/parse-test.rb +19 -0
  53. data/sample/sendmail.rb +94 -0
  54. data/test/extctrl.rb +6 -0
  55. data/test/fixtures/mailbox +414 -0
  56. data/test/fixtures/mailbox_without_any_from_or_sender +10 -0
  57. data/test/fixtures/mailbox_without_from +11 -0
  58. data/test/fixtures/mailbox_without_return_path +12 -0
  59. data/test/fixtures/raw_base64_decoded_string +0 -0
  60. data/test/fixtures/raw_base64_email +83 -0
  61. data/test/fixtures/raw_base64_encoded_string +1 -0
  62. data/test/fixtures/raw_email +14 -0
  63. data/test/fixtures/raw_email10 +20 -0
  64. data/test/fixtures/raw_email11 +34 -0
  65. data/test/fixtures/raw_email12 +32 -0
  66. data/test/fixtures/raw_email13 +29 -0
  67. data/test/fixtures/raw_email2 +114 -0
  68. data/test/fixtures/raw_email3 +70 -0
  69. data/test/fixtures/raw_email4 +59 -0
  70. data/test/fixtures/raw_email5 +19 -0
  71. data/test/fixtures/raw_email6 +20 -0
  72. data/test/fixtures/raw_email7 +66 -0
  73. data/test/fixtures/raw_email8 +47 -0
  74. data/test/fixtures/raw_email9 +28 -0
  75. data/test/fixtures/raw_email_quoted_with_0d0a +14 -0
  76. data/test/fixtures/raw_email_reply +32 -0
  77. data/test/fixtures/raw_email_simple +11 -0
  78. data/test/fixtures/raw_email_with_bad_date +48 -0
  79. data/test/fixtures/raw_email_with_illegal_boundary +58 -0
  80. data/test/fixtures/raw_email_with_multipart_mixed_quoted_boundary +50 -0
  81. data/test/fixtures/raw_email_with_nested_attachment +100 -0
  82. data/test/fixtures/raw_email_with_partially_quoted_subject +14 -0
  83. data/test/fixtures/raw_email_with_quoted_illegal_boundary +58 -0
  84. data/test/kcode.rb +14 -0
  85. data/test/test_address.rb +1211 -0
  86. data/test/test_attachments.rb +60 -0
  87. data/test/test_base64.rb +64 -0
  88. data/test/test_encode.rb +85 -0
  89. data/test/test_header.rb +969 -0
  90. data/test/test_helper.rb +9 -0
  91. data/test/test_mail.rb +753 -0
  92. data/test/test_mbox.rb +184 -0
  93. data/test/test_port.rb +436 -0
  94. data/test/test_quote.rb +98 -0
  95. data/test/test_scanner.rb +209 -0
  96. data/test/test_utils.rb +36 -0
  97. metadata +159 -0
@@ -0,0 +1,39 @@
1
+ #
2
+ # version.rb
3
+ #
4
+ #--
5
+ # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining
8
+ # a copy of this software and associated documentation files (the
9
+ # "Software"), to deal in the Software without restriction, including
10
+ # without limitation the rights to use, copy, modify, merge, publish,
11
+ # distribute, sublicense, and/or sell copies of the Software, and to
12
+ # permit persons to whom the Software is furnished to do so, subject to
13
+ # the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be
16
+ # included in all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+ #
26
+ # Note: Originally licensed under LGPL v2+. Using MIT license for Rails
27
+ # with permission of Minero Aoki.
28
+ #++
29
+
30
+ #:stopdoc:
31
+ module TMail
32
+ module VERSION
33
+ MAJOR = 1
34
+ MINOR = 2
35
+ TINY = 3
36
+
37
+ STRING = [MAJOR, MINOR, TINY].join('.')
38
+ end
39
+ end
@@ -0,0 +1,128 @@
1
+ # -x doc -x pkg -x log
2
+ CHANGES
3
+ LICENSE
4
+ NOTES
5
+ README
6
+ ext
7
+ ext/Makefile
8
+ ext/tmailscanner
9
+ ext/tmailscanner/tmail
10
+ ext/tmailscanner/tmail/MANIFEST
11
+ ext/tmailscanner/tmail/depend
12
+ ext/tmailscanner/tmail/extconf.rb
13
+ ext/tmailscanner/tmail/tmailscanner.c
14
+ lib
15
+ lib/tmail
16
+ lib/tmail/Makefile
17
+ lib/tmail/address.rb
18
+ lib/tmail/attachments.rb
19
+ lib/tmail/base64.rb
20
+ lib/tmail/compat.rb
21
+ lib/tmail/config.rb
22
+ lib/tmail/core_extensions.rb
23
+ lib/tmail/encode.rb
24
+ lib/tmail/header.rb
25
+ lib/tmail/index.rb
26
+ lib/tmail/interface.rb
27
+ lib/tmail/loader.rb
28
+ lib/tmail/mail.rb
29
+ lib/tmail/mailbox.rb
30
+ lib/tmail/main.rb
31
+ lib/tmail/mbox.rb
32
+ lib/tmail/net.rb
33
+ lib/tmail/obsolete.rb
34
+ lib/tmail/parser.rb
35
+ lib/tmail/parser.y
36
+ lib/tmail/port.rb
37
+ lib/tmail/quoting.rb
38
+ lib/tmail/require_arch.rb
39
+ lib/tmail/scanner.rb
40
+ lib/tmail/scanner_r.rb
41
+ lib/tmail/stringio.rb
42
+ lib/tmail/utils.rb
43
+ lib/tmail/version.rb
44
+ lib/tmail.rb
45
+ meta
46
+ meta/MANIFEST
47
+ meta/config.yaml
48
+ meta/icli.yaml
49
+ meta/project.yaml
50
+ meta/tmail.roll
51
+ sample
52
+ sample/bench_base64.rb
53
+ sample/data
54
+ sample/data/multipart
55
+ sample/data/normal
56
+ sample/data/sendtest
57
+ sample/data/simple
58
+ sample/data/test
59
+ sample/extract-attachements.rb
60
+ sample/from-check.rb
61
+ sample/multipart.rb
62
+ sample/parse-bench.rb
63
+ sample/parse-test.rb
64
+ sample/sendmail.rb
65
+ script
66
+ script/changelog
67
+ script/clobber
68
+ script/clobber/distclean
69
+ script/clobber/package
70
+ script/compile
71
+ script/pack
72
+ script/pack/gem
73
+ script/pack/tgz
74
+ script/pack/zip
75
+ script/prepare
76
+ script/publish
77
+ script/rdoc
78
+ script/release
79
+ script/setup
80
+ script/stamp
81
+ script/stats
82
+ script/tag
83
+ script/test
84
+ test
85
+ test/extctrl.rb
86
+ test/fixtures
87
+ test/fixtures/mailbox
88
+ test/fixtures/mailbox_without_any_from_or_sender
89
+ test/fixtures/mailbox_without_from
90
+ test/fixtures/mailbox_without_return_path
91
+ test/fixtures/raw_base64_decoded_string
92
+ test/fixtures/raw_base64_email
93
+ test/fixtures/raw_base64_encoded_string
94
+ test/fixtures/raw_email
95
+ test/fixtures/raw_email10
96
+ test/fixtures/raw_email11
97
+ test/fixtures/raw_email12
98
+ test/fixtures/raw_email13
99
+ test/fixtures/raw_email2
100
+ test/fixtures/raw_email3
101
+ test/fixtures/raw_email4
102
+ test/fixtures/raw_email5
103
+ test/fixtures/raw_email6
104
+ test/fixtures/raw_email7
105
+ test/fixtures/raw_email8
106
+ test/fixtures/raw_email9
107
+ test/fixtures/raw_email_quoted_with_0d0a
108
+ test/fixtures/raw_email_reply
109
+ test/fixtures/raw_email_simple
110
+ test/fixtures/raw_email_with_bad_date
111
+ test/fixtures/raw_email_with_illegal_boundary
112
+ test/fixtures/raw_email_with_multipart_mixed_quoted_boundary
113
+ test/fixtures/raw_email_with_nested_attachment
114
+ test/fixtures/raw_email_with_partially_quoted_subject
115
+ test/fixtures/raw_email_with_quoted_illegal_boundary
116
+ test/kcode.rb
117
+ test/test_address.rb
118
+ test/test_attachments.rb
119
+ test/test_base64.rb
120
+ test/test_encode.rb
121
+ test/test_header.rb
122
+ test/test_helper.rb
123
+ test/test_mail.rb
124
+ test/test_mbox.rb
125
+ test/test_port.rb
126
+ test/test_quote.rb
127
+ test/test_scanner.rb
128
+ test/test_utils.rb
@@ -0,0 +1,30 @@
1
+ ---
2
+ project : tmail
3
+ version : 1.2.3.1
4
+ status : production
5
+ title : TMail
6
+ brief : Ruby Mail Handler
7
+ contact : Mikel Lindsaar <raasdnil AT gmail.com>
8
+ email : tmail-talk@rubyforge.org
9
+ homepage: http://tmail.rubyforge.org
10
+ authors :
11
+ - Minero Aoki
12
+ - Mikel Lindsaar
13
+
14
+ description:
15
+ TMail is a Ruby-based mail handler. It allows you
16
+ to compose stadards compliant emails in a
17
+ very Ruby-way.
18
+
19
+ loadpath:
20
+ - lib
21
+ - ext/tmailscanner
22
+
23
+ exclude: [doc,work]
24
+
25
+ hosts:
26
+ rubyforge:
27
+ type: rubyforge
28
+ rubytalk:
29
+ type: rubytalk
30
+
@@ -0,0 +1 @@
1
+ tmail
@@ -0,0 +1,48 @@
1
+ # base64 benchmark
2
+ #
3
+ # pass 'c' as first argument to bench c lib.
4
+
5
+ require 'benchmark'
6
+
7
+ module TMail
8
+ module Base64
9
+ end
10
+ end
11
+
12
+ $lib = ARGV[0]
13
+ $count = 10000
14
+ $size = 5000
15
+
16
+ def make_random_string(len)
17
+ buf = ''
18
+ len.times do
19
+ buf << rand(255)
20
+ end
21
+ buf
22
+ end
23
+
24
+ def encode_and_decode(orig)
25
+ #ok = [orig].pack('m').delete("\r\n")
26
+ end
27
+
28
+ if $lib == "c"
29
+ $lib = " c"
30
+ require 'ext/base64_c/tmail/base64_c.bundle'
31
+ else
32
+ $lib = "ruby"
33
+ require 'lib/tmail/base64_r.rb'
34
+ end
35
+
36
+ def benchmark!
37
+ Benchmark.bm do |x|
38
+ x.report("#{$lib} #{$count.to_s}/#{$size}: ") do
39
+ $count.times do
40
+ orig = make_random_string($size)
41
+ result = TMail::Base64.encode(orig)
42
+ TMail::Base64.decode(result)
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ benchmark!
@@ -0,0 +1,23 @@
1
+ Date: Tue, 26 Jan 1999 23:17:34 +0900
2
+ From: aamine@dp.u-netsurf.ne.jp
3
+ To: ruby-list@netlab.co.jp
4
+ Mime-Version: 1.0
5
+ Content-Type: multipart/mixed;
6
+ boundary="Multipart_Tue_Jan_26_23:14:41_1999-1"
7
+ Content-Transfer-Encoding: 7bit
8
+
9
+ this is preamble
10
+
11
+ --Multipart_Tue_Jan_26_23:14:41_1999-1
12
+ Content-Type: text/plain; charset=iso-2022-jp
13
+
14
+ this is multi part body 1
15
+
16
+ --Multipart_Tue_Jan_26_23:14:41_1999-1
17
+ Content-Type: text/plain; charset=iso-2022-jp
18
+
19
+ multi part body, 2
20
+
21
+ --Multipart_Tue_Jan_26_23:14:41_1999-1--
22
+
23
+ epilogue
@@ -0,0 +1,29 @@
1
+ Received: from hoyogw.netlab.co.jp (daemon@hoyogw.netlab.co.jp [202.218.249.220])
2
+ by serv1.u-netsurf.ne.jp (8.8.8/3.6W-2.66(99/03/09)) with ESMTP id RAA10692
3
+ for <aamine@dp.u-netsurf.ne.jp>; Thu, 18 Mar 1999 17:35:23 +0900 (JST)
4
+ Received: from hoyogw.netlab.co.jp (matz@localhost [127.0.0.1])
5
+ by hoyogw.netlab.co.jp (8.9.1a+3.1W/3.7W/1.3) with SMTP id RAA13204;
6
+ Thu, 18 Mar 1999 17:21:58 +0900
7
+ Received: from blade.nagaokaut.ac.jp (sinara@blade.nagaokaut.ac.jp [133.44.36.60])
8
+ by hoyogw.netlab.co.jp (8.9.1a+3.1W/3.7W/1.3) with ESMTP id RAA13036
9
+ for <ruby-list@netlab.co.jp>; Thu, 18 Mar 1999 17:20:28 +0900
10
+ Received: (from sinara@localhost)
11
+ by blade.nagaokaut.ac.jp (8.8.8/8.8.8/Debian/GNU) id RAA22078;
12
+ Thu, 18 Mar 1999 17:20:49 +0900
13
+ Posted: Thu, 18 Mar 1999 17:20:49 +0900
14
+ Reply-To: ruby-list@netlab.co.jp
15
+ Subject: [ruby-list:12994] Re: Sieve of Eratosthenes (Re: [ruby-dev:6094])
16
+ Message-Id: <199903180820.RAA22078@blade.nagaokaut.ac.jp>
17
+ In-Reply-To: message of "Wed, 17 Mar 1999 18:42:07 +0900"
18
+ <199903170941.SAA12014@blade.nagaokaut.ac.jp>
19
+ Mime-Version: 1.0
20
+ Content-Type: text/plain; charset = iso-2022-jp
21
+ Content-Transfer-Encoding: 7bit
22
+ Date: Thu, 18 Mar 1999 17:21:54 +0900
23
+ To: ruby-list@netlab.co.jp (ruby mailing list)
24
+ From: (this is comment) local@dom1.dom2
25
+ Subject: this is a test subject
26
+
27
+ line 1
28
+ line 2
29
+ line 3
@@ -0,0 +1,5 @@
1
+ To: Minero Aoki <aamine@harmony.softica.or.jp>
2
+ From: Minero Aoki <aamine@harmony.softica.or.jp>
3
+ Subject: Sendmail test by tmail
4
+
5
+ This is mail sent by tmail.
@@ -0,0 +1,14 @@
1
+ To: これはデコード済 <aamine@dp.u-netsurf.ne.jp>
2
+ From: =?iso-2022-jp?B?GyRCJDMkbCRPJSglcyUzITwlSSQ1JGwkRiQkJD8bKEI=?=
3
+ <myself@softica.or.jp>
4
+ Received: from fromdom.fromdom by bydom.bydom
5
+ via VIAPATH with SMTP id <msgid@tmail> for addr@spec
6
+ ; 23 Mar 1999 22:05:33 +0900
7
+ Mime-Version: 1.0
8
+ Content-Type: text/plain; charset=iso-2022-jp
9
+ Content-Transfer-Encoding: 7bit
10
+ Subject: this is a test subject
11
+
12
+ body line 1
13
+ body line 2
14
+ body line 3
@@ -0,0 +1,27 @@
1
+ Received: from hoyogw.netlab.co.jp (matz@localhost [127.0.0.1])
2
+ by hoyogw.netlab.co.jp (8.9.1a+3.1W/3.7W/1.3)
3
+ with SMTP id RAA13204;
4
+ Thu, 18 Mar 1999 17:21:58 +0900
5
+ Received: from fromdom.fromdom by bydom.bydom
6
+ via VIAPATH with SMTP id <msgid@tmail> for addr@spec;
7
+ 23 Mar 1999 22:05:33 +0900
8
+ Date: Thu, 18 Mar 1999 17:21:54 +0900
9
+ To: ����ϥǥ����ɺ� <"aamine@"@dp.u-netsurf.ne.jp> (Minero Aoki)
10
+ Cc:
11
+ Bcc: =?iso-2022-jp?B?GyRCJDMkbCRPJUclMyE8JUk6URsoQg==?=
12
+ =?iso-2022-jp?B?PGFhbWluZUBkcC51LW5ldHN1cmYubmUuanA+?=
13
+ From: =?iso-2022-jp?B?GyRCJDMkbCRPJSglcyUzITwlSSQ1JGwkRiQkJD8bKEI=?=
14
+ (From comment) (comment2) <myself@softica.or.jp>
15
+ Posted: Thu, 18 Mar 1999 17:20:49 +0900
16
+ Reply-To: ruby-list@netlab.co.jp
17
+ Subject: [ruby-list:12994] Re: Sieve of Eratosthenes
18
+ Message-Id: <199903180820.RAA22078@blade.nagaokaut.ac.jp>
19
+ In-Reply-To: "Wed, 17 Mar 1999 18:42:07 +0900"
20
+ <199903170941.SAA12014@blade.nagaokaut.ac.jp>
21
+ Mime-Version: 1.0
22
+ Content-Type: text/plain; charset=iso-2022-jp
23
+ Content-Transfer-Encoding: 7bit
24
+
25
+ line 1
26
+ line 2
27
+ line 3
@@ -0,0 +1,33 @@
1
+ #
2
+ # extract-attachments.rb -- Extracts attachment(s) from the message.
3
+ #
4
+ # Usage: ruby extract-attachments.rb mail mail...
5
+ #
6
+
7
+ require 'tmail'
8
+
9
+ def main
10
+ idx = 1
11
+ ARGV.each do |fname|
12
+ TMail::Mail.load(fname).parts.each do |m|
13
+ m.base64_decode
14
+ File.open("#{idx}.#{ext(m)}", 'w') {|f|
15
+ f.write m.body
16
+ }
17
+ idx += 1
18
+ end
19
+ end
20
+ end
21
+
22
+ CTYPE_TO_EXT = {
23
+ 'image/jpeg' => 'jpeg',
24
+ 'image/gif' => 'gif',
25
+ 'image/png' => 'png',
26
+ 'image/tiff' => 'tiff'
27
+ }
28
+
29
+ def ext( mail )
30
+ CTYPE_TO_EXT[mail.content_type] || 'txt'
31
+ end
32
+
33
+ main
@@ -0,0 +1,26 @@
1
+ #
2
+ # checking mail From: header
3
+ #
4
+
5
+ require 'tmail'
6
+
7
+ unless ARGV[0] then
8
+ $stderr.puts "usage: ruby fromcheck.rb <mhdir>"
9
+ exit 1
10
+ end
11
+
12
+ table = {} # from-addr-spec => [count, friendly-from]
13
+ ld = TMail::MhLoader.new( ARGV[0] )
14
+ ld.each_port do |port|
15
+ mail = TMail::Mail.new( port )
16
+ addr, = mail.from_addrs
17
+ if addr then
18
+ (table[addr.spec] ||= [0, mail.friendly_from])[0] += 1
19
+ end
20
+ end
21
+
22
+ table.to_a.sort {|a,b|
23
+ b[1][0] <=> a[1][0]
24
+ }.each_with_index do |(spec,(n,from)), i|
25
+ printf "%3d %-33s %d\n", i+1, from, n
26
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # MIME multipart parsing test
3
+ #
4
+
5
+ require 'tmail'
6
+
7
+ mail = TMail::Mail.load( ARGV[0] || 'data/multipart' )
8
+
9
+ puts '========= preamble =============='
10
+ puts mail.body
11
+ puts
12
+
13
+ puts '========== parts ================'
14
+ mail.parts.each_with_index do |i,idx|
15
+ puts "<#{idx+1}>"
16
+ puts i
17
+ puts
18
+ end
19
+
20
+ puts '========= epilogue =============='
21
+ puts mail.epilogue
22
+ puts
23
+
24
+ puts "========= re-struct ============="
25
+ puts mail.decoded
26
+ puts