actionmailer-rack-upgrade 2.3.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/CHANGELOG +387 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README +149 -0
  4. data/Rakefile +97 -0
  5. data/install.rb +30 -0
  6. data/lib/action_mailer/adv_attr_accessor.rb +30 -0
  7. data/lib/action_mailer/base.rb +739 -0
  8. data/lib/action_mailer/helpers.rb +113 -0
  9. data/lib/action_mailer/mail_helper.rb +17 -0
  10. data/lib/action_mailer/part.rb +107 -0
  11. data/lib/action_mailer/part_container.rb +55 -0
  12. data/lib/action_mailer/quoting.rb +62 -0
  13. data/lib/action_mailer/test_case.rb +64 -0
  14. data/lib/action_mailer/test_helper.rb +68 -0
  15. data/lib/action_mailer/utils.rb +7 -0
  16. data/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb +1466 -0
  17. data/lib/action_mailer/vendor/text_format.rb +10 -0
  18. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/Makefile +18 -0
  19. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/address.rb +392 -0
  20. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/attachments.rb +65 -0
  21. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/base64.rb +46 -0
  22. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/compat.rb +41 -0
  23. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/config.rb +67 -0
  24. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/core_extensions.rb +63 -0
  25. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/encode.rb +590 -0
  26. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/header.rb +962 -0
  27. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/index.rb +9 -0
  28. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/interface.rb +1162 -0
  29. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/loader.rb +3 -0
  30. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/mail.rb +578 -0
  31. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/mailbox.rb +496 -0
  32. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/main.rb +6 -0
  33. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/mbox.rb +3 -0
  34. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/net.rb +250 -0
  35. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/obsolete.rb +132 -0
  36. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/parser.rb +1060 -0
  37. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/parser.y +416 -0
  38. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/port.rb +379 -0
  39. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/quoting.rb +164 -0
  40. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/require_arch.rb +58 -0
  41. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/scanner.rb +49 -0
  42. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/scanner_r.rb +262 -0
  43. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/stringio.rb +280 -0
  44. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/utils.rb +362 -0
  45. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/COPYING +504 -0
  46. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/README +12 -0
  47. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/big5freq.rb +927 -0
  48. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/big5prober.rb +42 -0
  49. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb +238 -0
  50. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/charsetgroupprober.rb +112 -0
  51. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/charsetprober.rb +75 -0
  52. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/codingstatemachine.rb +64 -0
  53. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/constants.rb +42 -0
  54. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/escprober.rb +89 -0
  55. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/escsm.rb +244 -0
  56. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/eucjpprober.rb +88 -0
  57. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euckrfreq.rb +596 -0
  58. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euckrprober.rb +42 -0
  59. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euctwfreq.rb +430 -0
  60. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/euctwprober.rb +42 -0
  61. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/gb2312freq.rb +474 -0
  62. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/gb2312prober.rb +42 -0
  63. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb +289 -0
  64. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/jisfreq.rb +570 -0
  65. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/jpcntx.rb +229 -0
  66. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langbulgarianmodel.rb +229 -0
  67. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langcyrillicmodel.rb +330 -0
  68. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langgreekmodel.rb +227 -0
  69. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langhebrewmodel.rb +202 -0
  70. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langhungarianmodel.rb +226 -0
  71. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/langthaimodel.rb +201 -0
  72. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/latin1prober.rb +147 -0
  73. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcharsetprober.rb +89 -0
  74. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcsgroupprober.rb +45 -0
  75. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/mbcssm.rb +542 -0
  76. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/sbcharsetprober.rb +124 -0
  77. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/sbcsgroupprober.rb +56 -0
  78. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/sjisprober.rb +88 -0
  79. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/universaldetector.rb +168 -0
  80. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/utf8prober.rb +87 -0
  81. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet.rb +67 -0
  82. data/lib/action_mailer/vendor/tmail-1.2.7/tmail/version.rb +39 -0
  83. data/lib/action_mailer/vendor/tmail-1.2.7/tmail.rb +6 -0
  84. data/lib/action_mailer/vendor/tmail.rb +17 -0
  85. data/lib/action_mailer/version.rb +9 -0
  86. data/lib/action_mailer.rb +62 -0
  87. data/lib/actionmailer.rb +2 -0
  88. data/test/abstract_unit.rb +62 -0
  89. data/test/asset_host_test.rb +54 -0
  90. data/test/delivery_method_test.rb +51 -0
  91. data/test/fixtures/asset_host_mailer/email_with_asset.html.erb +1 -0
  92. data/test/fixtures/auto_layout_mailer/hello.html.erb +1 -0
  93. data/test/fixtures/auto_layout_mailer/multipart.text.html.erb +1 -0
  94. data/test/fixtures/auto_layout_mailer/multipart.text.plain.erb +1 -0
  95. data/test/fixtures/explicit_layout_mailer/logout.html.erb +1 -0
  96. data/test/fixtures/explicit_layout_mailer/signup.html.erb +1 -0
  97. data/test/fixtures/first_mailer/share.erb +1 -0
  98. data/test/fixtures/helper_mailer/use_example_helper.erb +1 -0
  99. data/test/fixtures/helper_mailer/use_helper.erb +1 -0
  100. data/test/fixtures/helper_mailer/use_helper_method.erb +1 -0
  101. data/test/fixtures/helper_mailer/use_mail_helper.erb +5 -0
  102. data/test/fixtures/helpers/example_helper.rb +5 -0
  103. data/test/fixtures/layouts/auto_layout_mailer.html.erb +1 -0
  104. data/test/fixtures/layouts/auto_layout_mailer.text.erb +1 -0
  105. data/test/fixtures/layouts/spam.html.erb +1 -0
  106. data/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.erb +1 -0
  107. data/test/fixtures/raw_email +14 -0
  108. data/test/fixtures/raw_email10 +20 -0
  109. data/test/fixtures/raw_email12 +32 -0
  110. data/test/fixtures/raw_email13 +29 -0
  111. data/test/fixtures/raw_email2 +114 -0
  112. data/test/fixtures/raw_email3 +70 -0
  113. data/test/fixtures/raw_email4 +59 -0
  114. data/test/fixtures/raw_email5 +19 -0
  115. data/test/fixtures/raw_email6 +20 -0
  116. data/test/fixtures/raw_email7 +66 -0
  117. data/test/fixtures/raw_email8 +47 -0
  118. data/test/fixtures/raw_email9 +28 -0
  119. data/test/fixtures/raw_email_quoted_with_0d0a +14 -0
  120. data/test/fixtures/raw_email_with_invalid_characters_in_content_type +104 -0
  121. data/test/fixtures/raw_email_with_nested_attachment +100 -0
  122. data/test/fixtures/raw_email_with_partially_quoted_subject +14 -0
  123. data/test/fixtures/second_mailer/share.erb +1 -0
  124. data/test/fixtures/templates/signed_up.erb +3 -0
  125. data/test/fixtures/test_mailer/_subtemplate.text.plain.erb +1 -0
  126. data/test/fixtures/test_mailer/body_ivar.erb +2 -0
  127. data/test/fixtures/test_mailer/custom_templating_extension.text.html.haml +6 -0
  128. data/test/fixtures/test_mailer/custom_templating_extension.text.plain.haml +6 -0
  129. data/test/fixtures/test_mailer/implicitly_multipart_example.ignored.erb +1 -0
  130. data/test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak +1 -0
  131. data/test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb +10 -0
  132. data/test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb~ +10 -0
  133. data/test/fixtures/test_mailer/implicitly_multipart_example.text.plain.erb +2 -0
  134. data/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.erb +1 -0
  135. data/test/fixtures/test_mailer/included_subtemplate.text.plain.erb +1 -0
  136. data/test/fixtures/test_mailer/rxml_template.builder +2 -0
  137. data/test/fixtures/test_mailer/rxml_template.rxml +2 -0
  138. data/test/fixtures/test_mailer/signed_up.html.erb +3 -0
  139. data/test/fixtures/test_mailer/signed_up_with_url.erb +5 -0
  140. data/test/mail_helper_test.rb +95 -0
  141. data/test/mail_layout_test.rb +123 -0
  142. data/test/mail_render_test.rb +116 -0
  143. data/test/mail_service_test.rb +1145 -0
  144. data/test/quoting_test.rb +105 -0
  145. data/test/test_helper_test.rb +129 -0
  146. data/test/tmail_test.rb +22 -0
  147. data/test/url_test.rb +76 -0
  148. metadata +209 -0
@@ -0,0 +1,250 @@
1
+ #--
2
+ # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #
23
+ # Note: Originally licensed under LGPL v2+. Using MIT license for Rails
24
+ # with permission of Minero Aoki.
25
+ #++
26
+
27
+ #:stopdoc:
28
+ require 'nkf'
29
+ #:startdoc:
30
+
31
+ module TMail
32
+
33
+ class Mail
34
+
35
+ def send_to( smtp )
36
+ do_send_to(smtp) do
37
+ ready_to_send
38
+ end
39
+ end
40
+
41
+ def send_text_to( smtp )
42
+ do_send_to(smtp) do
43
+ ready_to_send
44
+ mime_encode
45
+ end
46
+ end
47
+
48
+ def do_send_to( smtp )
49
+ from = from_address or raise ArgumentError, 'no from address'
50
+ (dests = destinations).empty? and raise ArgumentError, 'no receipient'
51
+ yield
52
+ send_to_0 smtp, from, dests
53
+ end
54
+ private :do_send_to
55
+
56
+ def send_to_0( smtp, from, to )
57
+ smtp.ready(from, to) do |f|
58
+ encoded "\r\n", 'j', f, ''
59
+ end
60
+ end
61
+
62
+ def ready_to_send
63
+ delete_no_send_fields
64
+ add_message_id
65
+ add_date
66
+ end
67
+
68
+ NOSEND_FIELDS = %w(
69
+ received
70
+ bcc
71
+ )
72
+
73
+ def delete_no_send_fields
74
+ NOSEND_FIELDS.each do |nm|
75
+ delete nm
76
+ end
77
+ delete_if {|n,v| v.empty? }
78
+ end
79
+
80
+ def add_message_id( fqdn = nil )
81
+ unless @message_id_enforced
82
+ self.message_id = ::TMail::new_message_id(fqdn)
83
+ end
84
+ end
85
+
86
+ def add_date
87
+ self.date = Time.now
88
+ end
89
+
90
+ def mime_encode
91
+ if parts.empty?
92
+ mime_encode_singlepart
93
+ else
94
+ mime_encode_multipart true
95
+ end
96
+ end
97
+
98
+ def mime_encode_singlepart
99
+ self.mime_version = '1.0'
100
+ b = body
101
+ if NKF.guess(b) != NKF::BINARY
102
+ mime_encode_text b
103
+ else
104
+ mime_encode_binary b
105
+ end
106
+ end
107
+
108
+ def mime_encode_text( body )
109
+ self.body = NKF.nkf('-j -m0', body)
110
+ self.set_content_type 'text', 'plain', {'charset' => 'iso-2022-jp'}
111
+ self.encoding = '7bit'
112
+ end
113
+
114
+ def mime_encode_binary( body )
115
+ self.body = [body].pack('m')
116
+ self.set_content_type 'application', 'octet-stream'
117
+ self.encoding = 'Base64'
118
+ end
119
+
120
+ def mime_encode_multipart( top = true )
121
+ self.mime_version = '1.0' if top
122
+ self.set_content_type 'multipart', 'mixed'
123
+ e = encoding(nil)
124
+ if e and not /\A(?:7bit|8bit|binary)\z/i === e
125
+ raise ArgumentError,
126
+ 'using C.T.Encoding with multipart mail is not permitted'
127
+ end
128
+ end
129
+
130
+ end
131
+
132
+ #:stopdoc:
133
+ class DeleteFields
134
+
135
+ NOSEND_FIELDS = %w(
136
+ received
137
+ bcc
138
+ )
139
+
140
+ def initialize( nosend = nil, delempty = true )
141
+ @no_send_fields = nosend || NOSEND_FIELDS.dup
142
+ @delete_empty_fields = delempty
143
+ end
144
+
145
+ attr :no_send_fields
146
+ attr :delete_empty_fields, true
147
+
148
+ def exec( mail )
149
+ @no_send_fields.each do |nm|
150
+ delete nm
151
+ end
152
+ delete_if {|n,v| v.empty? } if @delete_empty_fields
153
+ end
154
+
155
+ end
156
+ #:startdoc:
157
+
158
+ #:stopdoc:
159
+ class AddMessageId
160
+
161
+ def initialize( fqdn = nil )
162
+ @fqdn = fqdn
163
+ end
164
+
165
+ attr :fqdn, true
166
+
167
+ def exec( mail )
168
+ mail.message_id = ::TMail::new_msgid(@fqdn)
169
+ end
170
+
171
+ end
172
+ #:startdoc:
173
+
174
+ #:stopdoc:
175
+ class AddDate
176
+
177
+ def exec( mail )
178
+ mail.date = Time.now
179
+ end
180
+
181
+ end
182
+ #:startdoc:
183
+
184
+ #:stopdoc:
185
+ class MimeEncodeAuto
186
+
187
+ def initialize( s = nil, m = nil )
188
+ @singlepart_composer = s || MimeEncodeSingle.new
189
+ @multipart_composer = m || MimeEncodeMulti.new
190
+ end
191
+
192
+ attr :singlepart_composer
193
+ attr :multipart_composer
194
+
195
+ def exec( mail )
196
+ if mail._builtin_multipart?
197
+ then @multipart_composer
198
+ else @singlepart_composer end.exec mail
199
+ end
200
+
201
+ end
202
+ #:startdoc:
203
+
204
+ #:stopdoc:
205
+ class MimeEncodeSingle
206
+
207
+ def exec( mail )
208
+ mail.mime_version = '1.0'
209
+ b = mail.body
210
+ if NKF.guess(b) != NKF::BINARY
211
+ on_text b
212
+ else
213
+ on_binary b
214
+ end
215
+ end
216
+
217
+ def on_text( body )
218
+ mail.body = NKF.nkf('-j -m0', body)
219
+ mail.set_content_type 'text', 'plain', {'charset' => 'iso-2022-jp'}
220
+ mail.encoding = '7bit'
221
+ end
222
+
223
+ def on_binary( body )
224
+ mail.body = [body].pack('m')
225
+ mail.set_content_type 'application', 'octet-stream'
226
+ mail.encoding = 'Base64'
227
+ end
228
+
229
+ end
230
+ #:startdoc:
231
+
232
+ #:stopdoc:
233
+ class MimeEncodeMulti
234
+
235
+ def exec( mail, top = true )
236
+ mail.mime_version = '1.0' if top
237
+ mail.set_content_type 'multipart', 'mixed'
238
+ e = encoding(nil)
239
+ if e and not /\A(?:7bit|8bit|binary)\z/i === e
240
+ raise ArgumentError,
241
+ 'using C.T.Encoding with multipart mail is not permitted'
242
+ end
243
+ mail.parts.each do |m|
244
+ exec m, false if m._builtin_multipart?
245
+ end
246
+ end
247
+
248
+ end
249
+ #:startdoc:
250
+ end # module TMail
@@ -0,0 +1,132 @@
1
+ =begin rdoc
2
+
3
+ = Obsolete methods that are depriciated
4
+
5
+ If you really want to see them, go to lib/tmail/obsolete.rb and view to your
6
+ heart's content.
7
+
8
+ =end
9
+ #--
10
+ # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>
11
+ #
12
+ # Permission is hereby granted, free of charge, to any person obtaining
13
+ # a copy of this software and associated documentation files (the
14
+ # "Software"), to deal in the Software without restriction, including
15
+ # without limitation the rights to use, copy, modify, merge, publish,
16
+ # distribute, sublicense, and/or sell copies of the Software, and to
17
+ # permit persons to whom the Software is furnished to do so, subject to
18
+ # the following conditions:
19
+ #
20
+ # The above copyright notice and this permission notice shall be
21
+ # included in all copies or substantial portions of the Software.
22
+ #
23
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
+ #
31
+ # Note: Originally licensed under LGPL v2+. Using MIT license for Rails
32
+ # with permission of Minero Aoki.
33
+ #++
34
+ #:stopdoc:
35
+ module TMail #:nodoc:
36
+
37
+ class Mail
38
+ alias include? key?
39
+ alias has_key? key?
40
+
41
+ def values
42
+ ret = []
43
+ each_field {|v| ret.push v }
44
+ ret
45
+ end
46
+
47
+ def value?( val )
48
+ HeaderField === val or return false
49
+
50
+ [ @header[val.name.downcase] ].flatten.include? val
51
+ end
52
+
53
+ alias has_value? value?
54
+ end
55
+
56
+ class Mail
57
+ def from_addr( default = nil )
58
+ addr, = from_addrs(nil)
59
+ addr || default
60
+ end
61
+
62
+ def from_address( default = nil )
63
+ if a = from_addr(nil)
64
+ a.spec
65
+ else
66
+ default
67
+ end
68
+ end
69
+
70
+ alias from_address= from_addrs=
71
+
72
+ def from_phrase( default = nil )
73
+ if a = from_addr(nil)
74
+ a.phrase
75
+ else
76
+ default
77
+ end
78
+ end
79
+
80
+ alias msgid message_id
81
+ alias msgid= message_id=
82
+
83
+ alias each_dest each_destination
84
+ end
85
+
86
+ class Address
87
+ alias route routes
88
+ alias addr spec
89
+
90
+ def spec=( str )
91
+ @local, @domain = str.split(/@/,2).map {|s| s.split(/\./) }
92
+ end
93
+
94
+ alias addr= spec=
95
+ alias address= spec=
96
+ end
97
+
98
+ class MhMailbox
99
+ alias new_mail new_port
100
+ alias each_mail each_port
101
+ alias each_newmail each_new_port
102
+ end
103
+ class UNIXMbox
104
+ alias new_mail new_port
105
+ alias each_mail each_port
106
+ alias each_newmail each_new_port
107
+ end
108
+ class Maildir
109
+ alias new_mail new_port
110
+ alias each_mail each_port
111
+ alias each_newmail each_new_port
112
+ end
113
+
114
+ extend TextUtils
115
+
116
+ class << self
117
+ alias msgid? message_id?
118
+ alias boundary new_boundary
119
+ alias msgid new_message_id
120
+ alias new_msgid new_message_id
121
+ end
122
+
123
+ def Mail.boundary
124
+ ::TMail.new_boundary
125
+ end
126
+
127
+ def Mail.msgid
128
+ ::TMail.new_message_id
129
+ end
130
+
131
+ end # module TMail
132
+ #:startdoc: