tmail 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +50 -5
- data/MANIFEST +188 -0
- data/NOTES +1 -1
- data/README +10 -4
- data/Rakefile +1 -10
- data/lib/tmail.rb +1 -0
- data/lib/tmail/Makefile +0 -1
- data/lib/tmail/address.rb +190 -17
- data/lib/tmail/attachments.rb +1 -1
- data/lib/tmail/base64.rb +4 -10
- data/lib/tmail/compat.rb +8 -6
- data/lib/tmail/config.rb +2 -6
- data/lib/tmail/core_extensions.rb +14 -18
- data/lib/tmail/encode.rb +47 -12
- data/lib/tmail/header.rb +7 -10
- data/lib/tmail/index.rb +2 -1
- data/lib/tmail/interface.rb +14 -12
- data/lib/tmail/loader.rb +2 -0
- data/lib/tmail/mail.rb +83 -24
- data/lib/tmail/mailbox.rb +70 -10
- data/lib/tmail/main.rb +2 -0
- data/lib/tmail/mbox.rb +2 -0
- data/lib/tmail/net.rb +16 -15
- data/lib/tmail/obsolete.rb +7 -12
- data/lib/tmail/parser.rb +1 -0
- data/lib/tmail/require_arch.rb +2 -0
- data/lib/tmail/scanner.rb +2 -1
- data/lib/tmail/scanner_r.rb +11 -10
- data/lib/tmail/utils.rb +83 -26
- data/lib/tmail/version.rb +3 -2
- data/log/BugTrackingLog.txt +1208 -0
- data/log/{ChangeLog.txt → Changelog-0.txt} +36 -0
- data/log/Changelog.txt +534 -0
- data/log/Testlog.txt +114 -0
- data/log/Todo.txt +0 -2
- data/meta/VERSION +1 -0
- data/meta/project.yaml +8 -5
- data/meta/unixname +1 -0
- data/setup.rb +1481 -0
- data/site/contributing/index.html +183 -0
- data/site/css/clean.css +27 -0
- data/site/css/layout.css +31 -0
- data/site/css/style.css +60 -0
- data/site/download/index.html +61 -0
- data/site/img/envelope.jpg +0 -0
- data/site/img/mailman.gif +0 -0
- data/site/img/stamp-sm.jpg +0 -0
- data/site/img/stamp.jpg +0 -0
- data/site/img/stampborder.jpg +0 -0
- data/site/img/tfire.jpg +0 -0
- data/site/img/tmail.png +0 -0
- data/site/index.html +270 -0
- data/site/js/jquery.js +31 -0
- data/site/log/Changelog.xsl +33 -0
- data/site/log/changelog.xml +1677 -0
- data/site/outdated/BUGS +3 -0
- data/site/outdated/DEPENDS +1 -0
- data/site/outdated/Incompatibilities +89 -0
- data/site/outdated/Incompatibilities.ja +102 -0
- data/site/outdated/NEWS +9 -0
- data/site/outdated/README.ja +73 -0
- data/site/outdated/doc.ja/address.html +275 -0
- data/site/outdated/doc.ja/basics.html +405 -0
- data/site/outdated/doc.ja/config.html +49 -0
- data/site/outdated/doc.ja/details.html +146 -0
- data/site/outdated/doc.ja/index.html +39 -0
- data/site/outdated/doc.ja/mail.html +793 -0
- data/site/outdated/doc.ja/mailbox.html +265 -0
- data/site/outdated/doc.ja/port.html +95 -0
- data/site/outdated/doc.ja/tmail.html +58 -0
- data/site/outdated/doc.ja/usage.html +202 -0
- data/site/outdated/rdd/address.rrd.m +229 -0
- data/site/outdated/rdd/basics.rd.m +275 -0
- data/site/outdated/rdd/config.rrd.m +26 -0
- data/site/outdated/rdd/details.rd.m +117 -0
- data/site/outdated/rdd/index.rhtml.m +54 -0
- data/site/outdated/rdd/mail.rrd.m +701 -0
- data/site/outdated/rdd/mailbox.rrd.m +228 -0
- data/site/outdated/rdd/port.rrd.m +69 -0
- data/site/outdated/rdd/tmail.rrd.m +33 -0
- data/site/outdated/rdd/usage.rd.m +247 -0
- data/site/quickstart/index.html +69 -0
- data/site/quickstart/quickstart.html +52 -0
- data/site/quickstart/usage.html +193 -0
- data/site/reference/address.html +247 -0
- data/site/reference/config.html +30 -0
- data/site/reference/index.html +101 -0
- data/site/reference/mail.html +726 -0
- data/site/reference/mailbox.html +245 -0
- data/site/reference/port.html +75 -0
- data/site/reference/tmail.html +35 -0
- data/test/fixtures/mailbox +405 -4
- data/test/fixtures/raw_email_multiple_from +30 -0
- data/test/kcode.rb +2 -2
- data/test/temp_test_one.rb +46 -0
- data/test/test_address.rb +77 -38
- data/test/test_encode.rb +0 -2
- data/test/test_header.rb +47 -24
- data/test/test_mail.rb +52 -9
- data/test/test_mbox.rb +28 -0
- data/test/test_port.rb +33 -27
- data/test/test_quote.rb +35 -8
- data/work/script/make +26 -0
- data/work/script/rdoc +39 -0
- data/{script → work/script}/setup +0 -0
- data/work/script/test +30 -0
- metadata +249 -184
- data/log/History.txt +0 -40
- data/meta/config.yaml +0 -8
- data/meta/icli.yaml +0 -16
- data/meta/tmail.roll +0 -3
- data/script/changelog +0 -19
- data/script/clobber/distclean +0 -8
- data/script/clobber/package +0 -10
- data/script/compile +0 -32
- data/script/pack/gem +0 -93
- data/script/pack/tgz +0 -41
- data/script/pack/zip +0 -41
- data/script/prepare +0 -15
- data/script/publish +0 -51
- data/script/rdoc +0 -42
- data/script/release +0 -10
- data/script/stamp +0 -33
- data/script/stats +0 -138
- data/script/tag +0 -25
- data/script/test +0 -36
data/lib/tmail/attachments.rb
CHANGED
data/lib/tmail/base64.rb
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Base64
|
4
|
-
#
|
5
|
-
# = COPYRIGHT:
|
6
|
-
#
|
1
|
+
#--
|
7
2
|
# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
|
8
3
|
#
|
9
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
@@ -27,10 +22,9 @@
|
|
27
22
|
#
|
28
23
|
# Note: Originally licensed under LGPL v2+. Using MIT license for Rails
|
29
24
|
# with permission of Minero Aoki.
|
30
|
-
|
31
|
-
|
25
|
+
#++
|
26
|
+
#:stopdoc:
|
32
27
|
module TMail
|
33
|
-
|
34
28
|
module Base64
|
35
29
|
|
36
30
|
module_function
|
@@ -48,5 +42,5 @@ module TMail
|
|
48
42
|
end
|
49
43
|
|
50
44
|
end
|
51
|
-
|
52
45
|
end
|
46
|
+
#:startdoc:
|
data/lib/tmail/compat.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
#:stopdoc:
|
2
|
+
unless Enumerable.method_defined?(:map)
|
3
|
+
module Enumerable #:nodoc:
|
3
4
|
alias map collect
|
4
5
|
end
|
5
6
|
end
|
6
7
|
|
7
8
|
unless Enumerable.method_defined?(:select)
|
8
|
-
module Enumerable
|
9
|
+
module Enumerable #:nodoc:
|
9
10
|
alias select find_all
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
14
|
unless Enumerable.method_defined?(:reject)
|
14
|
-
module Enumerable
|
15
|
+
module Enumerable #:nodoc:
|
15
16
|
def reject
|
16
17
|
result = []
|
17
18
|
each do |i|
|
@@ -23,7 +24,7 @@ unless Enumerable.method_defined?(:reject)
|
|
23
24
|
end
|
24
25
|
|
25
26
|
unless Enumerable.method_defined?(:sort_by)
|
26
|
-
module Enumerable
|
27
|
+
module Enumerable #:nodoc:
|
27
28
|
def sort_by
|
28
29
|
map {|i| [yield(i), i] }.sort.map {|val, i| i }
|
29
30
|
end
|
@@ -31,9 +32,10 @@ unless Enumerable.method_defined?(:sort_by)
|
|
31
32
|
end
|
32
33
|
|
33
34
|
unless File.respond_to?(:read)
|
34
|
-
def File.read(fname)
|
35
|
+
def File.read(fname) #:nodoc:
|
35
36
|
File.open(fname) {|f|
|
36
37
|
return f.read
|
37
38
|
}
|
38
39
|
end
|
39
40
|
end
|
41
|
+
#:startdoc:
|
data/lib/tmail/config.rb
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
=begin rdoc
|
2
|
-
|
3
|
-
= Configuration Class
|
4
|
-
|
5
|
-
=end
|
6
1
|
#--
|
7
2
|
# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
|
8
3
|
#
|
@@ -28,7 +23,7 @@
|
|
28
23
|
# Note: Originally licensed under LGPL v2+. Using MIT license for Rails
|
29
24
|
# with permission of Minero Aoki.
|
30
25
|
#++
|
31
|
-
|
26
|
+
#:stopdoc:
|
32
27
|
module TMail
|
33
28
|
|
34
29
|
class Config
|
@@ -69,3 +64,4 @@ module TMail
|
|
69
64
|
end
|
70
65
|
|
71
66
|
end
|
67
|
+
#:startdoc:
|
@@ -1,14 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
= Ruby on Rails Core Extensions
|
4
|
-
|
5
|
-
provides .blank?
|
6
|
-
|
7
|
-
=end
|
8
|
-
unless Object.respond_to?(:blank?) #:nodoc:
|
9
|
-
# Check first to see if we are in a Rails environment, no need to
|
10
|
-
# define these methods if we are
|
1
|
+
#:stopdoc:
|
2
|
+
unless Object.respond_to?(:blank?)
|
11
3
|
class Object
|
4
|
+
# Check first to see if we are in a Rails environment, no need to
|
5
|
+
# define these methods if we are
|
6
|
+
|
12
7
|
# An object is blank if it's nil, empty, or a whitespace string.
|
13
8
|
# For example, "", " ", nil, [], and {} are blank.
|
14
9
|
#
|
@@ -27,41 +22,42 @@ unless Object.respond_to?(:blank?) #:nodoc:
|
|
27
22
|
end
|
28
23
|
end
|
29
24
|
|
30
|
-
class NilClass
|
25
|
+
class NilClass
|
31
26
|
def blank?
|
32
27
|
true
|
33
28
|
end
|
34
29
|
end
|
35
30
|
|
36
|
-
class FalseClass
|
31
|
+
class FalseClass
|
37
32
|
def blank?
|
38
33
|
true
|
39
34
|
end
|
40
35
|
end
|
41
36
|
|
42
|
-
class TrueClass
|
37
|
+
class TrueClass
|
43
38
|
def blank?
|
44
39
|
false
|
45
40
|
end
|
46
41
|
end
|
47
42
|
|
48
|
-
class Array
|
43
|
+
class Array
|
49
44
|
alias_method :blank?, :empty?
|
50
45
|
end
|
51
46
|
|
52
|
-
class Hash
|
47
|
+
class Hash
|
53
48
|
alias_method :blank?, :empty?
|
54
49
|
end
|
55
50
|
|
56
|
-
class String
|
51
|
+
class String
|
57
52
|
def blank?
|
58
53
|
empty? || strip.empty?
|
59
54
|
end
|
60
55
|
end
|
61
56
|
|
62
|
-
class Numeric
|
57
|
+
class Numeric
|
63
58
|
def blank?
|
64
59
|
false
|
65
60
|
end
|
66
61
|
end
|
67
|
-
end
|
62
|
+
end
|
63
|
+
#:startdoc:
|
data/lib/tmail/encode.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Text Encoding class
|
4
|
-
#
|
1
|
+
#--
|
5
2
|
# = COPYRIGHT:
|
6
3
|
#
|
7
4
|
# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
|
@@ -27,14 +24,22 @@
|
|
27
24
|
#
|
28
25
|
# Note: Originally licensed under LGPL v2+. Using MIT license for Rails
|
29
26
|
# with permission of Minero Aoki.
|
30
|
-
|
27
|
+
#++
|
28
|
+
#:stopdoc:
|
31
29
|
require 'nkf'
|
32
30
|
require 'tmail/base64'
|
33
31
|
require 'tmail/stringio'
|
34
32
|
require 'tmail/utils'
|
33
|
+
#:startdoc:
|
35
34
|
|
36
35
|
|
37
36
|
module TMail
|
37
|
+
|
38
|
+
#:stopdoc:
|
39
|
+
class << self
|
40
|
+
attr_accessor :KCODE
|
41
|
+
end
|
42
|
+
self.KCODE = 'NONE'
|
38
43
|
|
39
44
|
module StrategyInterface
|
40
45
|
|
@@ -52,10 +57,34 @@ module TMail
|
|
52
57
|
end
|
53
58
|
module_function :create_dest
|
54
59
|
|
60
|
+
#:startdoc:
|
61
|
+
# Returns the TMail object encoded and ready to be sent via SMTP etc.
|
62
|
+
# You should call this before you are packaging up your email to
|
63
|
+
# correctly escape all the values that need escaping in the email, line
|
64
|
+
# wrap the email etc.
|
65
|
+
#
|
66
|
+
# It is also a good idea to call this before you marshal or serialize
|
67
|
+
# a TMail object.
|
68
|
+
#
|
69
|
+
# For Example:
|
70
|
+
#
|
71
|
+
# email = TMail::Load(my_email_file)
|
72
|
+
# email_to_send = email.encoded
|
55
73
|
def encoded( eol = "\r\n", charset = 'j', dest = nil )
|
56
74
|
accept_strategy Encoder, eol, charset, dest
|
57
75
|
end
|
58
76
|
|
77
|
+
# Returns the TMail object decoded and ready to be used by you, your
|
78
|
+
# program etc.
|
79
|
+
#
|
80
|
+
# You should call this before you are packaging up your email to
|
81
|
+
# correctly escape all the values that need escaping in the email, line
|
82
|
+
# wrap the email etc.
|
83
|
+
#
|
84
|
+
# For Example:
|
85
|
+
#
|
86
|
+
# email = TMail::Load(my_email_file)
|
87
|
+
# email_to_send = email.encoded
|
59
88
|
def decoded( eol = "\n", charset = 'e', dest = nil )
|
60
89
|
# Turn the E-Mail into a string and return it with all
|
61
90
|
# encoded characters decoded. alias for to_s
|
@@ -64,7 +93,7 @@ module TMail
|
|
64
93
|
|
65
94
|
alias to_s decoded
|
66
95
|
|
67
|
-
def accept_strategy( klass, eol, charset, dest = nil )
|
96
|
+
def accept_strategy( klass, eol, charset, dest = nil ) #:nodoc:
|
68
97
|
dest ||= ''
|
69
98
|
accept klass.new( create_dest(dest), charset, eol )
|
70
99
|
dest
|
@@ -72,6 +101,7 @@ module TMail
|
|
72
101
|
|
73
102
|
end
|
74
103
|
|
104
|
+
#:stopdoc:
|
75
105
|
|
76
106
|
###
|
77
107
|
### MIME B encoding decoder
|
@@ -90,8 +120,8 @@ module TMail
|
|
90
120
|
}
|
91
121
|
|
92
122
|
def self.decode( str, encoding = nil )
|
93
|
-
encoding ||= (OUTPUT_ENCODING[
|
94
|
-
opt = '-
|
123
|
+
encoding ||= (OUTPUT_ENCODING[TMail.KCODE] || 'j')
|
124
|
+
opt = '-mS' + encoding
|
95
125
|
str.gsub(ENCODED_WORDS) {|s| NKF.nkf(opt, s) }
|
96
126
|
end
|
97
127
|
|
@@ -193,7 +223,7 @@ module TMail
|
|
193
223
|
|
194
224
|
def initialize( dest = nil, encoding = nil, eol = "\r\n", limit = nil )
|
195
225
|
@f = StrategyInterface.create_dest(dest)
|
196
|
-
@opt = OPTIONS[
|
226
|
+
@opt = OPTIONS[TMail.KCODE]
|
197
227
|
@eol = eol
|
198
228
|
@folded = false
|
199
229
|
@preserve_quotes = true
|
@@ -368,11 +398,16 @@ module TMail
|
|
368
398
|
end
|
369
399
|
|
370
400
|
def concat_A_S( types, strs )
|
401
|
+
if RUBY_VERSION < '1.9'
|
402
|
+
a = ?a; s = ?s
|
403
|
+
else
|
404
|
+
a = 'a'.ord; s = 's'.ord
|
405
|
+
end
|
371
406
|
i = 0
|
372
407
|
types.each_byte do |t|
|
373
408
|
case t
|
374
|
-
when
|
375
|
-
when
|
409
|
+
when a then add_text strs[i]
|
410
|
+
when s then add_lwsp strs[i]
|
376
411
|
else
|
377
412
|
raise "TMail FATAL: unknown flag: #{t.chr}"
|
378
413
|
end
|
@@ -520,5 +555,5 @@ module TMail
|
|
520
555
|
end
|
521
556
|
|
522
557
|
end
|
523
|
-
|
558
|
+
#:startdoc:
|
524
559
|
end # module TMail
|
data/lib/tmail/header.rb
CHANGED
@@ -1,11 +1,3 @@
|
|
1
|
-
=begin rdoc
|
2
|
-
|
3
|
-
= Header handling class
|
4
|
-
|
5
|
-
=end
|
6
|
-
# RFC #822 ftp://ftp.isi.edu/in-notes/rfc822.txt
|
7
|
-
#
|
8
|
-
#
|
9
1
|
#--
|
10
2
|
# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
|
11
3
|
#
|
@@ -38,9 +30,10 @@ require 'tmail/parser'
|
|
38
30
|
require 'tmail/config'
|
39
31
|
require 'tmail/utils'
|
40
32
|
|
41
|
-
|
33
|
+
#:startdoc:
|
42
34
|
module TMail
|
43
35
|
|
36
|
+
# Provides methods to handle and manipulate headers in the email
|
44
37
|
class HeaderField
|
45
38
|
|
46
39
|
include TextUtils
|
@@ -214,7 +207,11 @@ module TMail
|
|
214
207
|
|
215
208
|
def comments
|
216
209
|
ensure_parsed
|
217
|
-
@comments
|
210
|
+
if @comments[0]
|
211
|
+
[Decoder.decode(@comments[0])]
|
212
|
+
else
|
213
|
+
@comments
|
214
|
+
end
|
218
215
|
end
|
219
216
|
|
220
217
|
private
|
data/lib/tmail/index.rb
CHANGED
data/lib/tmail/interface.rb
CHANGED
@@ -966,31 +966,33 @@ module TMail
|
|
966
966
|
end
|
967
967
|
end
|
968
968
|
|
969
|
-
#
|
969
|
+
# Convert the Mail object's body into a Base64 encoded email
|
970
970
|
# returning the modified Mail object
|
971
971
|
def base64_encode!
|
972
972
|
store 'Content-Transfer-Encoding', 'Base64'
|
973
|
-
self.body =
|
973
|
+
self.body = base64_encode
|
974
974
|
end
|
975
975
|
|
976
|
-
#
|
977
|
-
#
|
978
|
-
|
979
|
-
|
976
|
+
# Return the result of encoding the TMail::Mail object body
|
977
|
+
# without altering the current body
|
978
|
+
def base64_encode
|
979
|
+
Base64.folding_encode(self.body)
|
980
|
+
end
|
980
981
|
|
981
|
-
#
|
982
|
+
# Convert the Mail object's body into a Base64 decoded email
|
982
983
|
# returning the modified Mail object
|
983
984
|
def base64_decode!
|
984
985
|
if /base64/i === self.transfer_encoding('')
|
985
986
|
store 'Content-Transfer-Encoding', '8bit'
|
986
|
-
self.body =
|
987
|
+
self.body = base64_decode
|
987
988
|
end
|
988
989
|
end
|
989
990
|
|
990
|
-
#
|
991
|
-
#
|
992
|
-
|
993
|
-
|
991
|
+
# Returns the result of decoding the TMail::Mail object body
|
992
|
+
# without altering the current body
|
993
|
+
def base64_decode
|
994
|
+
Base64.decode(self.body, @config.strict_base64decode?)
|
995
|
+
end
|
994
996
|
|
995
997
|
# Returns an array of each destination in the email message including to: cc: or bcc:
|
996
998
|
#
|
data/lib/tmail/loader.rb
CHANGED
data/lib/tmail/mail.rb
CHANGED
@@ -28,22 +28,7 @@
|
|
28
28
|
# Note: Originally licensed under LGPL v2+. Using MIT license for Rails
|
29
29
|
# with permission of Minero Aoki.
|
30
30
|
#++
|
31
|
-
|
32
|
-
# === Class Methods
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
31
|
+
|
47
32
|
|
48
33
|
|
49
34
|
require 'tmail/interface'
|
@@ -58,23 +43,89 @@ require 'socket'
|
|
58
43
|
|
59
44
|
module TMail
|
60
45
|
|
46
|
+
# == Mail Class
|
47
|
+
#
|
48
|
+
# Accessing a TMail object done via the TMail::Mail class. As email can be fairly complex
|
49
|
+
# creatures, you will find a large amount of accessor and setter methods in this class!
|
50
|
+
#
|
51
|
+
# Most of the below methods handle the header, in fact, what TMail does best is handle the
|
52
|
+
# header of the email object. There are only a few methods that deal directly with the body
|
53
|
+
# of the email, such as base64_encode and base64_decode.
|
54
|
+
#
|
55
|
+
# === Using TMail inside your code
|
56
|
+
#
|
57
|
+
# The usual way is to install the gem (see the {README}[link:/README] on how to do this) and
|
58
|
+
# then put at the top of your class:
|
59
|
+
#
|
60
|
+
# require 'tmail'
|
61
|
+
#
|
62
|
+
# You can then create a new TMail object in your code with:
|
63
|
+
#
|
64
|
+
# @email = TMail::Mail.new
|
65
|
+
#
|
66
|
+
# Or if you have an email as a string, you can initialize a new TMail::Mail object and get it
|
67
|
+
# to parse that string for you like so:
|
68
|
+
#
|
69
|
+
# @email = TMail::Mail.parse(email_text)
|
70
|
+
#
|
71
|
+
# You can also read a single email off the disk, for example:
|
72
|
+
#
|
73
|
+
# @email = TMail::Mail.load('filename.txt')
|
74
|
+
#
|
75
|
+
# Also, you can read a mailbox (usual unix mbox format) and end up with an array of TMail
|
76
|
+
# objects by doing something like this:
|
77
|
+
#
|
78
|
+
# # Note, we pass true as the last variable to open the mailbox read only
|
79
|
+
# mailbox = TMail::UNIXMbox.new("mailbox", nil, true)
|
80
|
+
# @emails = []
|
81
|
+
# mailbox.each_port { |m| @emails << TMail::Mail.new(m) }
|
82
|
+
#
|
61
83
|
class Mail
|
62
84
|
|
63
85
|
class << self
|
86
|
+
|
87
|
+
# Opens an email that has been saved out as a file by itself.
|
88
|
+
#
|
89
|
+
# This function will read a file non-destructively and then parse
|
90
|
+
# the contents and return a TMail::Mail object.
|
91
|
+
#
|
92
|
+
# Does not handle multiple email mailboxes (like a unix mbox) for that
|
93
|
+
# use the TMail::UNIXMbox class.
|
94
|
+
#
|
95
|
+
# Example:
|
96
|
+
# mail = TMail::Mail.load('filename')
|
97
|
+
#
|
64
98
|
def load( fname )
|
65
99
|
new(FilePort.new(fname))
|
66
100
|
end
|
67
101
|
|
68
102
|
alias load_from load
|
69
103
|
alias loadfrom load
|
70
|
-
|
104
|
+
|
105
|
+
# Parses an email from the supplied string and returns a TMail::Mail
|
106
|
+
# object.
|
107
|
+
#
|
108
|
+
# Example:
|
109
|
+
# require 'rubygems'; require 'tmail'
|
110
|
+
# email_string =<<HEREDOC
|
111
|
+
# To: mikel@lindsaar.net
|
112
|
+
# From: mikel@me.com
|
113
|
+
# Subject: This is a short Email
|
114
|
+
#
|
115
|
+
# Hello there Mikel!
|
116
|
+
#
|
117
|
+
# HEREDOC
|
118
|
+
# mail = TMail::Mail.parse(email_string)
|
119
|
+
# #=> #<TMail::Mail port=#<TMail::StringPort:id=0xa30ac0> bodyport=nil>
|
120
|
+
# mail.body
|
121
|
+
# #=> "Hello there Mikel!\n\n"
|
71
122
|
def parse( str )
|
72
123
|
new(StringPort.new(str))
|
73
124
|
end
|
74
125
|
|
75
126
|
end
|
76
127
|
|
77
|
-
def initialize( port = nil, conf = DEFAULT_CONFIG )
|
128
|
+
def initialize( port = nil, conf = DEFAULT_CONFIG ) #:nodoc:
|
78
129
|
@port = port || StringPort.new
|
79
130
|
@config = Config.to_config(conf)
|
80
131
|
|
@@ -90,6 +141,12 @@ module TMail
|
|
90
141
|
}
|
91
142
|
end
|
92
143
|
|
144
|
+
# Provides access to the port this email is using to hold it's data
|
145
|
+
#
|
146
|
+
# Example:
|
147
|
+
# mail = TMail::Mail.parse(email_string)
|
148
|
+
# mail.port
|
149
|
+
# #=> #<TMail::StringPort:id=0xa2c952>
|
93
150
|
attr_reader :port
|
94
151
|
|
95
152
|
def inspect
|
@@ -395,10 +452,12 @@ module TMail
|
|
395
452
|
end
|
396
453
|
|
397
454
|
def quoted_body
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
455
|
+
body_port.ropen {|f| return f.read }
|
456
|
+
end
|
457
|
+
|
458
|
+
def quoted_body= str
|
459
|
+
body_port.wopen { |f| f.write str }
|
460
|
+
str
|
402
461
|
end
|
403
462
|
|
404
463
|
def body=( str )
|
@@ -420,8 +479,8 @@ module TMail
|
|
420
479
|
str
|
421
480
|
end
|
422
481
|
|
423
|
-
alias preamble
|
424
|
-
alias preamble=
|
482
|
+
alias preamble quoted_body
|
483
|
+
alias preamble= quoted_body=
|
425
484
|
|
426
485
|
def epilogue
|
427
486
|
parse_body
|