tmail 1.2.1 → 1.2.2
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.
- 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/CHANGES
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
=== 1.2.2 / 2008-03-07
|
|
2
|
+
|
|
3
|
+
* Fixed install bug with gem pacakge (1.2.1 was not compiling on gem install)
|
|
4
|
+
* A _LOT_ more documentation...!
|
|
5
|
+
* More documentation - (Mikel)
|
|
6
|
+
* Applied Ruby 1.9 patches to the library - All tests passing now - (Mikel)
|
|
7
|
+
* Closed #17719 - Fixed UNIXMbox code - readonly was not working and raising an exception. Now works.
|
|
8
|
+
* Closed #18038 - Multiple froms not being parsed correctly, added a test case to cover this and show the correct handling - (Mikel)
|
|
9
|
+
|
|
10
|
+
=== 1.2.1 / 2008-01-11
|
|
2
11
|
|
|
3
12
|
* More documentation (Mikel)
|
|
4
13
|
* Added 15 test cases from the Rails ActionMailer to TMail
|
|
@@ -9,8 +18,44 @@
|
|
|
9
18
|
* Closed #16899 - HeaderField.new_from_port and added test cases to cover this code (Maarten O.)
|
|
10
19
|
* Closed #16900 - UNIXMbox.fromaddr missing port param and does not return Envelope Sender (Maarten O.)
|
|
11
20
|
|
|
12
|
-
|
|
21
|
+
=== 1.2.0 / 2007-11-29
|
|
22
|
+
|
|
23
|
+
* 5 major enhancements:
|
|
24
|
+
* Extensive documentation work. (mikel)
|
|
25
|
+
* Renamed scanner_c.c to mailscanner.c. (trans)
|
|
26
|
+
* Removed base64 c extension. It's speed benefit was negligable (only 0.2 sec over 10000 sizable encode/decode runs) (trans)
|
|
27
|
+
* Closed 15445 - TMail::Mail#create_forward now returns a new Mail object that has the original mail as an encoded 7 bit multipart attachment. Also moved create_forward and create_reply from tmail/net into tmail/interface as it makes more sense to have it there. (mikel)
|
|
28
|
+
* Closed 15643 - TMail::Mail#reply_addresses was returning an empty array if reply_to was set to nil (ie, the header field existed but was empty) instead of returning the from address or default. (mikel)
|
|
29
|
+
* Closed 16025 - TMail scanner.rb would not parse ATOM chars correctly making it fail tests where the C version passed them. Fixed this by updating the Scanner.rb version to be in step with the C version (there was an extra @ symbol in the ATOM CHARS definition that was not in the C version.) (mikel)
|
|
30
|
+
* Fixed scanner.rb so that it would pass the same tests that the C version does - had a sundry @ symbol inside of the ATOM CHARS
|
|
31
|
+
* 3 minor enhancements:
|
|
32
|
+
* Renamed scanner_c.c to tmailscanner.c (trans)
|
|
33
|
+
* Changed TMail::Mail#sender to have a default "default" value of nil to be in alignment with all the other interface methods (mikel)
|
|
34
|
+
* Made base64_decode and base64_encode into ! versions as they are destructive on the mail body (encodes the body to base64 or decodes it), made aliases for base64_decode and base64_encode to point back to the bang versions. Doing this with a view to change base64_encode to a non destructive version (returns the encoded body) in future versions. (mikel)
|
|
35
|
+
|
|
36
|
+
=== 1.1.1 / 2007-11-05
|
|
37
|
+
|
|
38
|
+
* 3 major enhancement:
|
|
39
|
+
* Created unified package, for installation in any platform.
|
|
40
|
+
* Added require_arch.rb to facilitate multi-platform support.
|
|
41
|
+
* If compilation fails, set NORUBYEXT="true" and reinstall.
|
|
42
|
+
* 3 minor enhancement:
|
|
43
|
+
* Fixed line wrapping of long header fields so that they wrap at the correct whitespace points.
|
|
44
|
+
* Fixed bug where re-assigning the mail.body to existing mail object that already had a parsed body would not re-parse the body.
|
|
45
|
+
* Started documenting the source code... lots more to do.
|
|
46
|
+
|
|
47
|
+
=== 1.1.0 / 2007-10-28
|
|
48
|
+
|
|
49
|
+
* 1 minor enhancements:
|
|
50
|
+
* Changed the quoting of paramaters in the header fields to wrap double quotes around fields that are needed to be quoted.
|
|
51
|
+
* Removed keeping double quotes around a filename that does not need double quotes per RFC 1521
|
|
52
|
+
* More clean up and getting tests passing. Now standing at 2 failures out of 3366 assertions. One is the incorrect handling of "@"@test.com (returns @@test.com) and the other is a japanese encoding issue.
|
|
53
|
+
|
|
54
|
+
=== 1.0.0 / 2007-10-28
|
|
55
|
+
|
|
56
|
+
* 1 major enhancement:
|
|
57
|
+
* TMail is now released as a GEM!
|
|
58
|
+
* 2 minor enhancements:
|
|
59
|
+
* Fixed bug 15077 - TMail now recognizes attachments as soon as they are added to the body.
|
|
60
|
+
* Refactored handling of quotations in header fields - now cleaner
|
|
13
61
|
|
|
14
|
-
* Extensive documentation work. (mikel)
|
|
15
|
-
* Renamed scanner_c.c to mailscanner.c.
|
|
16
|
-
* Removed base64 c extension. It's speed benefit was negligable (only 0.2 sec over 10000 sizable encode/decode runs).
|
data/MANIFEST
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Rakefile
|
|
2
|
+
doc
|
|
3
|
+
test
|
|
4
|
+
test/temp_test_one.rb
|
|
5
|
+
test/kcode.rb
|
|
6
|
+
test/test_utils.rb
|
|
7
|
+
test/test_attachments.rb
|
|
8
|
+
test/test_encode.rb
|
|
9
|
+
test/test_mbox.rb
|
|
10
|
+
test/test_helper.rb
|
|
11
|
+
test/test_header.rb
|
|
12
|
+
test/test_base64.rb
|
|
13
|
+
test/test_address.rb
|
|
14
|
+
test/fixtures
|
|
15
|
+
test/fixtures/raw_email8
|
|
16
|
+
test/fixtures/raw_email_simple
|
|
17
|
+
test/fixtures/raw_email13
|
|
18
|
+
test/fixtures/raw_email5
|
|
19
|
+
test/fixtures/mailbox_without_any_from_or_sender
|
|
20
|
+
test/fixtures/raw_email4
|
|
21
|
+
test/fixtures/mailbox
|
|
22
|
+
test/fixtures/raw_email_with_nested_attachment
|
|
23
|
+
test/fixtures/raw_email
|
|
24
|
+
test/fixtures/raw_email_quoted_with_0d0a
|
|
25
|
+
test/fixtures/raw_base64_decoded_string
|
|
26
|
+
test/fixtures/mailbox_without_return_path
|
|
27
|
+
test/fixtures/raw_email3
|
|
28
|
+
test/fixtures/raw_email_reply
|
|
29
|
+
test/fixtures/raw_email_with_bad_date
|
|
30
|
+
test/fixtures/mailbox_without_from
|
|
31
|
+
test/fixtures/raw_email_multiple_from
|
|
32
|
+
test/fixtures/raw_email10
|
|
33
|
+
test/fixtures/raw_email_with_quoted_illegal_boundary
|
|
34
|
+
test/fixtures/raw_base64_email
|
|
35
|
+
test/fixtures/raw_email_with_partially_quoted_subject
|
|
36
|
+
test/fixtures/raw_email9
|
|
37
|
+
test/fixtures/raw_email2
|
|
38
|
+
test/fixtures/raw_email11
|
|
39
|
+
test/fixtures/raw_email_with_multipart_mixed_quoted_boundary
|
|
40
|
+
test/fixtures/raw_email_with_illegal_boundary
|
|
41
|
+
test/fixtures/raw_email6
|
|
42
|
+
test/fixtures/raw_email7
|
|
43
|
+
test/fixtures/raw_base64_encoded_string
|
|
44
|
+
test/fixtures/raw_email12
|
|
45
|
+
test/test_mail.rb
|
|
46
|
+
test/test_scanner.rb
|
|
47
|
+
test/test_port.rb
|
|
48
|
+
test/extctrl.rb
|
|
49
|
+
test/test_quote.rb
|
|
50
|
+
NOTES
|
|
51
|
+
CHANGES
|
|
52
|
+
LICENSE
|
|
53
|
+
README
|
|
54
|
+
ext
|
|
55
|
+
ext/tmailscanner
|
|
56
|
+
ext/tmailscanner/tmail
|
|
57
|
+
ext/tmailscanner/tmail/depend
|
|
58
|
+
ext/tmailscanner/tmail/MANIFEST
|
|
59
|
+
ext/tmailscanner/tmail/extconf.rb
|
|
60
|
+
ext/tmailscanner/tmail/tmailscanner.c
|
|
61
|
+
ext/Makefile
|
|
62
|
+
setup.rb
|
|
63
|
+
meta
|
|
64
|
+
meta/MANIFEST
|
|
65
|
+
meta/project.yaml
|
|
66
|
+
meta/unixname
|
|
67
|
+
meta/VERSION
|
|
68
|
+
site
|
|
69
|
+
site/img
|
|
70
|
+
site/img/tfire.jpg
|
|
71
|
+
site/img/stamp.jpg
|
|
72
|
+
site/img/tmail.png
|
|
73
|
+
site/img/mailman.gif
|
|
74
|
+
site/img/envelope.jpg
|
|
75
|
+
site/img/stamp-sm.jpg
|
|
76
|
+
site/img/stampborder.jpg
|
|
77
|
+
site/quickstart
|
|
78
|
+
site/quickstart/usage.html
|
|
79
|
+
site/quickstart/index.html
|
|
80
|
+
site/quickstart/quickstart.html
|
|
81
|
+
site/js
|
|
82
|
+
site/js/jquery.js
|
|
83
|
+
site/outdated
|
|
84
|
+
site/outdated/DEPENDS
|
|
85
|
+
site/outdated/Incompatibilities
|
|
86
|
+
site/outdated/Incompatibilities.ja
|
|
87
|
+
site/outdated/README.ja
|
|
88
|
+
site/outdated/NEWS
|
|
89
|
+
site/outdated/doc.ja
|
|
90
|
+
site/outdated/doc.ja/config.html
|
|
91
|
+
site/outdated/doc.ja/usage.html
|
|
92
|
+
site/outdated/doc.ja/mailbox.html
|
|
93
|
+
site/outdated/doc.ja/mail.html
|
|
94
|
+
site/outdated/doc.ja/index.html
|
|
95
|
+
site/outdated/doc.ja/basics.html
|
|
96
|
+
site/outdated/doc.ja/tmail.html
|
|
97
|
+
site/outdated/doc.ja/address.html
|
|
98
|
+
site/outdated/doc.ja/details.html
|
|
99
|
+
site/outdated/doc.ja/port.html
|
|
100
|
+
site/outdated/rdd
|
|
101
|
+
site/outdated/rdd/mail.rrd.m
|
|
102
|
+
site/outdated/rdd/port.rrd.m
|
|
103
|
+
site/outdated/rdd/config.rrd.m
|
|
104
|
+
site/outdated/rdd/index.rhtml.m
|
|
105
|
+
site/outdated/rdd/mailbox.rrd.m
|
|
106
|
+
site/outdated/rdd/usage.rd.m
|
|
107
|
+
site/outdated/rdd/basics.rd.m
|
|
108
|
+
site/outdated/rdd/details.rd.m
|
|
109
|
+
site/outdated/rdd/tmail.rrd.m
|
|
110
|
+
site/outdated/rdd/address.rrd.m
|
|
111
|
+
site/outdated/BUGS
|
|
112
|
+
site/index.html
|
|
113
|
+
site/contributing
|
|
114
|
+
site/contributing/index.html
|
|
115
|
+
site/reference
|
|
116
|
+
site/reference/config.html
|
|
117
|
+
site/reference/mailbox.html
|
|
118
|
+
site/reference/mail.html
|
|
119
|
+
site/reference/index.html
|
|
120
|
+
site/reference/tmail.html
|
|
121
|
+
site/reference/address.html
|
|
122
|
+
site/reference/port.html
|
|
123
|
+
site/css
|
|
124
|
+
site/css/layout.css
|
|
125
|
+
site/css/style.css
|
|
126
|
+
site/css/clean.css
|
|
127
|
+
site/download
|
|
128
|
+
site/download/index.html
|
|
129
|
+
site/log
|
|
130
|
+
site/log/changelog.xml
|
|
131
|
+
site/log/Changelog.xsl
|
|
132
|
+
lib
|
|
133
|
+
lib/tmail.rb
|
|
134
|
+
lib/tmail
|
|
135
|
+
lib/tmail/base64.rb
|
|
136
|
+
lib/tmail/loader.rb
|
|
137
|
+
lib/tmail/main.rb
|
|
138
|
+
lib/tmail/scanner.rb
|
|
139
|
+
lib/tmail/require_arch.rb
|
|
140
|
+
lib/tmail/config.rb
|
|
141
|
+
lib/tmail/port.rb
|
|
142
|
+
lib/tmail/encode.rb
|
|
143
|
+
lib/tmail/scanner_r.rb
|
|
144
|
+
lib/tmail/parser.rb
|
|
145
|
+
lib/tmail/version.rb
|
|
146
|
+
lib/tmail/obsolete.rb
|
|
147
|
+
lib/tmail/parser.y
|
|
148
|
+
lib/tmail/quoting.rb
|
|
149
|
+
lib/tmail/mbox.rb
|
|
150
|
+
lib/tmail/Makefile
|
|
151
|
+
lib/tmail/stringio.rb
|
|
152
|
+
lib/tmail/utils.rb
|
|
153
|
+
lib/tmail/interface.rb
|
|
154
|
+
lib/tmail/attachments.rb
|
|
155
|
+
lib/tmail/index.rb
|
|
156
|
+
lib/tmail/mail.rb
|
|
157
|
+
lib/tmail/net.rb
|
|
158
|
+
lib/tmail/address.rb
|
|
159
|
+
lib/tmail/header.rb
|
|
160
|
+
lib/tmail/compat.rb
|
|
161
|
+
lib/tmail/mailbox.rb
|
|
162
|
+
lib/tmail/core_extensions.rb
|
|
163
|
+
sample
|
|
164
|
+
sample/extract-attachements.rb
|
|
165
|
+
sample/parse-test.rb
|
|
166
|
+
sample/bench_base64.rb
|
|
167
|
+
sample/multipart.rb
|
|
168
|
+
sample/parse-bench.rb
|
|
169
|
+
sample/data
|
|
170
|
+
sample/data/test
|
|
171
|
+
sample/data/normal
|
|
172
|
+
sample/data/simple
|
|
173
|
+
sample/data/multipart
|
|
174
|
+
sample/data/sendtest
|
|
175
|
+
sample/from-check.rb
|
|
176
|
+
sample/sendmail.rb
|
|
177
|
+
work
|
|
178
|
+
work/script
|
|
179
|
+
work/script/test
|
|
180
|
+
work/script/rdoc
|
|
181
|
+
work/script/setup
|
|
182
|
+
work/script/make
|
|
183
|
+
log
|
|
184
|
+
log/BugTrackingLog.txt
|
|
185
|
+
log/Changelog.txt
|
|
186
|
+
log/Changelog-0.txt
|
|
187
|
+
log/Todo.txt
|
|
188
|
+
log/Testlog.txt
|
data/NOTES
CHANGED
data/README
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
http://tmail.rubyforge.org/
|
|
4
4
|
|
|
5
|
-
Mikel Lindsaar
|
|
5
|
+
Mikel Lindsaar maintainer
|
|
6
6
|
Trans assitant developer
|
|
7
7
|
Minero Aoki original developer
|
|
8
8
|
|
|
@@ -14,11 +14,13 @@ TMail is used by the Ruby on Rails web framework as the Email abstraction layer
|
|
|
14
14
|
|
|
15
15
|
The goal of the TMail handling library is to be able to parse and handle raw Email sources and produce RFC compliant Emails as a result. If you find something that TMail does that violates an RFC, we want to know and we'll get it fixed fast.
|
|
16
16
|
|
|
17
|
-
==
|
|
17
|
+
== DOCUMENTATION:
|
|
18
|
+
|
|
19
|
+
The place you will want to look first is the TMail::Mail class. This has the vast majority of methods you will be using to talk to your TMail object.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
== FEATURES/PROBLEMS:
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
TMail is fairly RFC compliant on the handling of emails.
|
|
22
24
|
|
|
23
25
|
There are also some problems in the header handling, but for 99.9% of email, you will be fine. Usually, the problems revolve around parsing incomming emails and making sense of them.
|
|
24
26
|
|
|
@@ -123,6 +125,10 @@ If you now puts the email again, it will not be included:
|
|
|
123
125
|
|
|
124
126
|
You can just call to_s on any email to have it serialized out as a single string with the right number of line breaks and encodings.
|
|
125
127
|
|
|
128
|
+
== CONTRIBUTING:
|
|
129
|
+
|
|
130
|
+
You can visit the {Contributing to TMail}[link:http://tmail.rubyforge.org/contributing/] to find out how to contribute to TMail, developers are welcome and wanted!
|
|
131
|
+
|
|
126
132
|
== REQUIREMENTS:
|
|
127
133
|
|
|
128
134
|
* C compiler if you want the Ruby extension for Scanner
|
data/Rakefile
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
require
|
|
2
|
-
require 'rake'
|
|
3
|
-
require 'rake/testtask'
|
|
1
|
+
require File.join(File.dirname(__FILE__), "setup.rb")
|
|
4
2
|
|
|
5
|
-
# Run the unit tests
|
|
6
|
-
Rake::TestTask.new { |t|
|
|
7
|
-
t.libs << "test"
|
|
8
|
-
t.pattern = 'test/test_*.rb'
|
|
9
|
-
t.verbose = true
|
|
10
|
-
t.warning = false
|
|
11
|
-
}
|
data/lib/tmail.rb
CHANGED
data/lib/tmail/Makefile
CHANGED
data/lib/tmail/address.rb
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
= Address handling class
|
|
4
4
|
|
|
5
5
|
=end
|
|
6
|
-
#
|
|
7
6
|
#--
|
|
8
7
|
# Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
|
|
9
8
|
#
|
|
@@ -36,18 +35,105 @@ require 'tmail/parser'
|
|
|
36
35
|
|
|
37
36
|
module TMail
|
|
38
37
|
|
|
38
|
+
# = Class Address
|
|
39
|
+
#
|
|
40
|
+
# Provides a complete handling library for email addresses. Can parse a string of an
|
|
41
|
+
# address directly or take in preformatted addresses themseleves. Allows you to add
|
|
42
|
+
# and remove phrases from the front of the address and provides a compare function for
|
|
43
|
+
# email addresses.
|
|
44
|
+
#
|
|
45
|
+
# == Parsing and Handling a Valid Address:
|
|
46
|
+
#
|
|
47
|
+
# Just pass the email address in as a string to Address.parse:
|
|
48
|
+
#
|
|
49
|
+
# email = TMail::Address.parse('Mikel Lindsaar <mikel@lindsaar.net>)
|
|
50
|
+
# #=> #<TMail::Address mikel@lindsaar.net>
|
|
51
|
+
# email.address
|
|
52
|
+
# #=> "mikel@lindsaar.net"
|
|
53
|
+
# email.local
|
|
54
|
+
# #=> "mikel"
|
|
55
|
+
# email.domain
|
|
56
|
+
# #=> "lindsaar.net"
|
|
57
|
+
# email.name # Aliased as phrase as well
|
|
58
|
+
# #=> "Mikel Lindsaar"
|
|
59
|
+
#
|
|
60
|
+
# == Detecting an Invalid Address
|
|
61
|
+
#
|
|
62
|
+
# If you want to check the syntactical validity of an email address, just pass it to
|
|
63
|
+
# Address.parse and catch any SyntaxError:
|
|
64
|
+
#
|
|
65
|
+
# begin
|
|
66
|
+
# TMail::Mail.parse("mikel 2@@@@@ me .com")
|
|
67
|
+
# rescue TMail::SyntaxError
|
|
68
|
+
# puts("Invalid Email Address Detected")
|
|
69
|
+
# else
|
|
70
|
+
# puts("Address is valid")
|
|
71
|
+
# end
|
|
72
|
+
# #=> "Invalid Email Address Detected"
|
|
39
73
|
class Address
|
|
40
74
|
|
|
41
|
-
include TextUtils
|
|
42
|
-
|
|
75
|
+
include TextUtils #:nodoc:
|
|
76
|
+
|
|
77
|
+
# Sometimes you need to parse an address, TMail can do it for you and provide you with
|
|
78
|
+
# a fairly robust method of detecting a valid address.
|
|
79
|
+
#
|
|
80
|
+
# Takes in a string, returns a TMail::Address object.
|
|
81
|
+
#
|
|
82
|
+
# Raises a TMail::SyntaxError on invalid email format
|
|
43
83
|
def Address.parse( str )
|
|
44
|
-
Parser.parse :ADDRESS, str
|
|
84
|
+
Parser.parse :ADDRESS, special_quote_address(str)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def Address.special_quote_address(str) #:nodoc:
|
|
88
|
+
# Takes a string which is an address and adds quotation marks to special
|
|
89
|
+
# edge case methods that the RACC parser can not handle.
|
|
90
|
+
#
|
|
91
|
+
# Right now just handles two edge cases:
|
|
92
|
+
#
|
|
93
|
+
# Full stop as the last character of the display name:
|
|
94
|
+
# Mikel L. <mikel@me.com>
|
|
95
|
+
# Returns:
|
|
96
|
+
# "Mikel L." <mikel@me.com>
|
|
97
|
+
#
|
|
98
|
+
# Unquoted @ symbol in the display name:
|
|
99
|
+
# mikel@me.com <mikel@me.com>
|
|
100
|
+
# Returns:
|
|
101
|
+
# "mikel@me.com" <mikel@me.com>
|
|
102
|
+
#
|
|
103
|
+
# Any other address not matching these patterns just gets returned as is.
|
|
104
|
+
case
|
|
105
|
+
# This handles the missing "" in an older version of Apple Mail.app
|
|
106
|
+
# around the display name when the display name contains a '@'
|
|
107
|
+
# like 'mikel@me.com <mikel@me.com>'
|
|
108
|
+
# Just quotes it to: '"mikel@me.com" <mikel@me.com>'
|
|
109
|
+
when str =~ /\A([^"].+@.+[^"])\s(<.*?>)\Z/
|
|
110
|
+
return "\"#{$1}\" #{$2}"
|
|
111
|
+
# This handles cases where 'Mikel A. <mikel@me.com>' which is a trailing
|
|
112
|
+
# full stop before the address section. Just quotes it to
|
|
113
|
+
# '"Mikel A. <mikel@me.com>"
|
|
114
|
+
when str =~ /\A(.*?\.)\s(<.*?>)\Z/
|
|
115
|
+
return "\"#{$1}\" #{$2}"
|
|
116
|
+
else
|
|
117
|
+
str
|
|
118
|
+
end
|
|
45
119
|
end
|
|
46
120
|
|
|
47
|
-
def address_group?
|
|
121
|
+
def address_group? #:nodoc:
|
|
48
122
|
false
|
|
49
123
|
end
|
|
50
124
|
|
|
125
|
+
# Address.new(local, domain)
|
|
126
|
+
#
|
|
127
|
+
# Accepts:
|
|
128
|
+
#
|
|
129
|
+
# * local - Left of the at symbol
|
|
130
|
+
#
|
|
131
|
+
# * domain - Array of the domain split at the periods.
|
|
132
|
+
#
|
|
133
|
+
# For example:
|
|
134
|
+
#
|
|
135
|
+
# Address.new("mikel", ["lindsaar", "net"])
|
|
136
|
+
# #=> "#<TMail::Address mikel@lindsaar.net>"
|
|
51
137
|
def initialize( local, domain )
|
|
52
138
|
if domain
|
|
53
139
|
domain.each do |s|
|
|
@@ -58,8 +144,8 @@ module TMail
|
|
|
58
144
|
# This is to catch an unquoted "@" symbol in the local part of the
|
|
59
145
|
# address. Handles addresses like <"@"@me.com> and makes sure they
|
|
60
146
|
# stay like <"@"@me.com> (previously were becomming <@@me.com>)
|
|
61
|
-
if local.
|
|
62
|
-
@local = "\"#{local.
|
|
147
|
+
if local && (local.join == '@' || local.join =~ /\A[^"].*?@.*?[^"]\Z/)
|
|
148
|
+
@local = "\"#{local.join}\""
|
|
63
149
|
else
|
|
64
150
|
@local = local
|
|
65
151
|
end
|
|
@@ -69,33 +155,97 @@ module TMail
|
|
|
69
155
|
@routes = []
|
|
70
156
|
end
|
|
71
157
|
|
|
72
|
-
|
|
158
|
+
# Provides the name or 'phrase' of the email address.
|
|
159
|
+
#
|
|
160
|
+
# For Example:
|
|
161
|
+
#
|
|
162
|
+
# email = TMail::Address.parse("Mikel Lindsaar <mikel@lindsaar.net>")
|
|
163
|
+
# email.name
|
|
164
|
+
# #=> "Mikel Lindsaar"
|
|
165
|
+
def name
|
|
166
|
+
@name
|
|
167
|
+
end
|
|
73
168
|
|
|
169
|
+
# Setter method for the name or phrase of the email
|
|
170
|
+
#
|
|
171
|
+
# For Example:
|
|
172
|
+
#
|
|
173
|
+
# email = TMail::Address.parse("mikel@lindsaar.net")
|
|
174
|
+
# email.name
|
|
175
|
+
# #=> nil
|
|
176
|
+
# email.name = "Mikel Lindsaar"
|
|
177
|
+
# email.to_s
|
|
178
|
+
# #=> "Mikel Lindsaar <mikel@me.com>"
|
|
74
179
|
def name=( str )
|
|
75
180
|
@name = str
|
|
76
181
|
@name = nil if str and str.empty?
|
|
77
182
|
end
|
|
78
183
|
|
|
184
|
+
#:stopdoc:
|
|
79
185
|
alias phrase name
|
|
80
186
|
alias phrase= name=
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
187
|
+
#:startdoc:
|
|
188
|
+
|
|
189
|
+
# This is still here from RFC 822, and is now obsolete per RFC2822 Section 4.
|
|
190
|
+
#
|
|
191
|
+
# "When interpreting addresses, the route portion SHOULD be ignored."
|
|
192
|
+
#
|
|
193
|
+
# It is still here, so you can access it.
|
|
194
|
+
#
|
|
195
|
+
# Routes return the route portion at the front of the email address, if any.
|
|
196
|
+
#
|
|
197
|
+
# For Example:
|
|
198
|
+
# email = TMail::Address.parse( "<@sa,@another:Mikel@me.com>")
|
|
199
|
+
# => #<TMail::Address Mikel@me.com>
|
|
200
|
+
# email.to_s
|
|
201
|
+
# => "<@sa,@another:Mikel@me.com>"
|
|
202
|
+
# email.routes
|
|
203
|
+
# => ["sa", "another"]
|
|
204
|
+
def routes
|
|
205
|
+
@routes
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def inspect #:nodoc:
|
|
85
209
|
"#<#{self.class} #{address()}>"
|
|
86
210
|
end
|
|
87
211
|
|
|
212
|
+
# Returns the local part of the email address
|
|
213
|
+
#
|
|
214
|
+
# For Example:
|
|
215
|
+
#
|
|
216
|
+
# email = TMail::Address.parse("mikel@lindsaar.net")
|
|
217
|
+
# email.local
|
|
218
|
+
# #=> "mikel"
|
|
88
219
|
def local
|
|
89
220
|
return nil unless @local
|
|
90
221
|
return '""' if @local.size == 1 and @local[0].empty?
|
|
91
|
-
|
|
222
|
+
# Check to see if it is an array before trying to map it
|
|
223
|
+
if @local.respond_to?(:map)
|
|
224
|
+
@local.map {|i| quote_atom(i) }.join('.')
|
|
225
|
+
else
|
|
226
|
+
quote_atom(@local)
|
|
227
|
+
end
|
|
92
228
|
end
|
|
93
229
|
|
|
230
|
+
# Returns the domain part of the email address
|
|
231
|
+
#
|
|
232
|
+
# For Example:
|
|
233
|
+
#
|
|
234
|
+
# email = TMail::Address.parse("mikel@lindsaar.net")
|
|
235
|
+
# email.local
|
|
236
|
+
# #=> "lindsaar.net"
|
|
94
237
|
def domain
|
|
95
238
|
return nil unless @domain
|
|
96
239
|
join_domain(@domain)
|
|
97
240
|
end
|
|
98
241
|
|
|
242
|
+
# Returns the full specific address itself
|
|
243
|
+
#
|
|
244
|
+
# For Example:
|
|
245
|
+
#
|
|
246
|
+
# email = TMail::Address.parse("mikel@lindsaar.net")
|
|
247
|
+
# email.address
|
|
248
|
+
# #=> "mikel@lindsaar.net"
|
|
99
249
|
def spec
|
|
100
250
|
s = self.local
|
|
101
251
|
d = self.domain
|
|
@@ -106,18 +256,41 @@ module TMail
|
|
|
106
256
|
end
|
|
107
257
|
end
|
|
108
258
|
|
|
109
|
-
alias address
|
|
110
|
-
|
|
259
|
+
alias address spec
|
|
260
|
+
|
|
261
|
+
# Provides == function to the email. Only checks the actual address
|
|
262
|
+
# and ignores the name/phrase component
|
|
263
|
+
#
|
|
264
|
+
# For Example
|
|
265
|
+
#
|
|
266
|
+
# addr1 = TMail::Address.parse("My Address <mikel@lindsaar.net>")
|
|
267
|
+
# #=> "#<TMail::Address mikel@lindsaar.net>"
|
|
268
|
+
# addr2 = TMail::Address.parse("Another <mikel@lindsaar.net>")
|
|
269
|
+
# #=> "#<TMail::Address mikel@lindsaar.net>"
|
|
270
|
+
# addr1 == addr2
|
|
271
|
+
# #=> true
|
|
111
272
|
def ==( other )
|
|
112
273
|
other.respond_to? :spec and self.spec == other.spec
|
|
113
274
|
end
|
|
114
275
|
|
|
115
276
|
alias eql? ==
|
|
116
277
|
|
|
278
|
+
# Provides a unique hash value for this record against the local and domain
|
|
279
|
+
# parts, ignores the name/phrase value
|
|
280
|
+
#
|
|
281
|
+
# email = TMail::Address.parse("mikel@lindsaar.net")
|
|
282
|
+
# email.hash
|
|
283
|
+
# #=> 18767598
|
|
117
284
|
def hash
|
|
118
285
|
@local.hash ^ @domain.hash
|
|
119
286
|
end
|
|
120
287
|
|
|
288
|
+
# Duplicates a TMail::Address object returning the duplicate
|
|
289
|
+
#
|
|
290
|
+
# addr1 = TMail::Address.parse("mikel@lindsaar.net")
|
|
291
|
+
# addr2 = addr1.dup
|
|
292
|
+
# addr1.id == addr2.id
|
|
293
|
+
# #=> false
|
|
121
294
|
def dup
|
|
122
295
|
obj = self.class.new(@local.dup, @domain.dup)
|
|
123
296
|
obj.name = @name.dup if @name
|
|
@@ -125,9 +298,9 @@ module TMail
|
|
|
125
298
|
obj
|
|
126
299
|
end
|
|
127
300
|
|
|
128
|
-
include StrategyInterface
|
|
301
|
+
include StrategyInterface #:nodoc:
|
|
129
302
|
|
|
130
|
-
def accept( strategy, dummy1 = nil, dummy2 = nil )
|
|
303
|
+
def accept( strategy, dummy1 = nil, dummy2 = nil ) #:nodoc:
|
|
131
304
|
unless @local
|
|
132
305
|
strategy.meta '<>' # empty return-path
|
|
133
306
|
return
|