summaryrefslogtreecommitdiff
path: root/fml/doc/en/tutorial/module/Message.sgml
blob: 2eeb8b45924e42f4499426f43a468f407f50495f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!--
   $FML: Message.sgml,v 1.2 2003/08/03 01:47:17 fukachan Exp $
   $jaFML: Message.sgml,v 1.2 2003/04/15 14:51:42 fukachan Exp $
-->

<chapter id="module.mail.message">
	<title>
	Mail::Message Module
	</title>

<sect1 id="module.mail.message.overview">
	<title>
	Mail::Message Overview
	</title>

<para>
Mail::Message object provides several methods to analyze a message and
manipulate messages or parts of a message.
</para>

<para>
Precisely speaking, this module analyzes the specified mail message
and build a chain of Mail::Message objects.
<screen>
If not multipart

   header -> body

else if multipart

   header -> preamble -> part1 -> part2 -> ... -> trailor
</screen>
The link between objects is double link list. Mail::Message class
provides several methods to manipulate these structures.
</para>

<para>
Each part of this chain is a Mail::Message object. In other words, one
mail message consits of a chain of plural Mail::Message objects in
&fml8; internal.
</para>

<para>
For example, "header" is a Mail::Message, which type is
text/rfc822-headers and the data is stored as Mail::Header
object. Instead "part1" is a Mail::Message object, which type is
text/plain and the data is reference to the message string.
</para>

<para>
References:
<ulink url="../../en/modules/Mail/Message.txt">
Mail::Message module manual.
</ulink>
</para>

</sect1>


<sect1 id="module.mail.message.parse">
	<title>
	Mail::Message Module: Analyze
	</title>

<para>
parse() analyzes the file. The argument is the file name or the file
handle for the file which should be specified at the argument.
</para>

<para>
data_type_list() returns information of the chain.
The return value is array reference.
For example, MIME/multipart consists of the following objects.
<screen>
  type[ 1]: text/rfc822-headers       | multipart/mixed
  type[ 2]: multipart/mixed           | multipart/mixed
  type[ 3]: multipart.preamble        | multipart/mixed
  type[ 4]: multipart.delimiter       | multipart/mixed
  type[ 5]: text/plain                | multipart/mixed
  type[ 6]: multipart.delimiter       | multipart/mixed
  type[ 7]: image/gif                 | multipart/mixed
  type[ 8]: multipart.close-delimiter | multipart/mixed
  type[ 9]: text/plain                | multipart/mixed
</screen>
The center row is the object type, the right one is the mime type of
the whole message (content-type in the mail header).
</para>

</sect1>


<sect1 id="module.mail.message.create">
	<title>
	Mail::Message Module: Create A New Object
	</title>

<para>
new() method is used to create a new object chain.
</para>

<para>
The following MIME/multipart specific methdos exist.
<screen>
build_mime_multipart_chain($args)
parse_and_build_mime_multipart_chain($args)
build_mime_header($args)
</screen>
These methods are used internally now.
So these will become private methods in the furure.
Please do not use these methods.
</para>

<para>
To create a new MIME/mulitpart message, use Mail::Message::Compose. It
is MIME::Lite class in fact :-)
</para>

</sect1>


<sect1 id="module.mail.message.headerop">
	<title>
	Mail::Message Module: Header Manipulations
	</title>

<para>
dup_header() method duplicates only header part of a chain and left
the body part as it is. The new chain has different head (header
object) but others begining from the second part is same as the
original chain.
<screen>
              |<--------------- mail body ------------->
header0 ----> part1 -> part2 -> ...
               A
               |
dup_header0 ---
</screen>
</para>


<para>
whole_message_header() returns the header object of the chain. The
return value is a Mail::Message object not string.
</para>

<para>
header_data_type() returns the type of the whole message as string.
It tells whether this message is text or multipart.
</para>

</sect1>


<sect1 id="module.mail.message.bodyop">
	<title>
	Mail::Message Module: Manipulate Messabe Body
	</title>

<para>
Consider the following object chain.
<screen>
If not multipart

header -> body

else if multipart

header -> preamble -> part1 -> part2 -> ... -> trailor
</screen>
</para>


<para>
header_data_type() return the type of the whole type.
It is known from Content-Type: in the whole message header.
</para>

<para>
whole_message_body() returns body or part1 if multipart.
whole_message_body_head() is same.
</para>

<para>
find_first_plaintext_message($args) return the first text/plain type
object in the chain. This is useful in filter codes since filter
system checks the first text field in a lot of cases.
</para>

</sect1>


<sect1 id="module.mail.message.search">
	<title>
	Mail::Message Module: Search
	</title>

<para>
find() searches the specified type of Mail::Message in the object
chain and returns the first matched object.
</para>

</sect1>


<sect1 id="module.mail.message.print">
	<title>
	Mail::Message Module: Print
	</title>

<para>
print() method is usual print() function. Usually specify the file
descriptor as an argument.
</para>

<para>
print() has the concept "mode" to specify CRLF or LF. use
set_print_mode(mode) and reset_print_mode() to set the mode. By
default, mode is raw. Specify smtp mode in using print() within SMTP
codes.
</para>

</sect1>


<sect1 id="module.mail.message.utils">
	<title>
	Mail::Message Module: Utility Functions
	</title>

<sect2>
	<title>
	Size
	</title>

<para>
size() returns the size of the object not the whole message size.
<!--
header_size() tells the size of the header.
body_size() tells the size of the body part.
-->
</para>

<para>
is_empty() tells the object data is empty or not. 
</para>
</sect2>


<sect2>
	<title>
	General Information
	</title>

<para>
envelope_sender() returns the envelope sender as string.
</para>

<para>
data_type() returns the type of the object (a part of an object chain)
not the whole message type (Content-Type: in the whole message
header).
</para>

<para>
encoding_mechanism() returns the encoding mechanism of the object (a
part of an object chain) as string. This is not of the whole message
encoding mechanism.
</para>

</sect2>


<sect2>
	<title>
	Mail::Message Internals
	</title>

<para>
num_paragraph() returns the number of paragraphs in the data of the
object.
</para>


<para>
nth_paragraph(N) returns N-th paragrah as the string.
Caution that N starts from 1 not 0.
</para>


<para>
header() returns the header part of a multipart block (header part of
an object). data() returns the data part (data part of an object).
Respectively, alias of message_fields($size) and message_text($size).
</para>

</sect2>

</sect1>


<sect1 id="module.mail.message.ref">
	<title>
	References
	</title>

<para>

<ulink url="../../en/modules/Mail/Message.txt">
Mail::Message manual
</ulink>
</para>
</sect1>


</chapter>