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 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701
|
@nocode MH
= class TMail::Mail
== Class Methods
: new(port = TMail::StringPort.new, config = DEFAULT_CONFIG) -> TMail::Mail
port: TMail::Port
config: TMail::Config
j
port Mail ֥Ȥޤ
e
creates a new 'TMail::Mail' object from PORT.
.
: load(filename) -> TMail::Mail
filename: String
j
ե filename ɤ Mail ֥Ȥޤ
ɤե MH ΥΤ褦˥̤եҤȤĤ
бƤʤФޤ
,UNIX mbox Τ褦ʷñȤǤбƤޤ
<a href="mbox.html">ܥå饹</a>ȤäƤ
e
creates a new 'TMail::Mail' object. FILENAME is the name of file
which contains just one mail (e.g. MH mail file).
.
: parse(str) -> TMail::Mail
str: String
j
ʸ str ѡ TMail::Mail ֥Ȥޤ
str ϥʬǤʤФޤ
e
parses STR and creates a new 'TMail::Mail' object.
.
== Instance Methods
: port -> TMail::Port
j
Υ륪֥ȤΥݡȤǤ
e
the source port of this mail.
.
: body_port -> TMail::Port
j
ʸ¸ƤݡȤ֤ޤ
˽ǤɸΥե(ʸ)ѹޤ
ºݤѹ뤿ˤϤΥݡȤ˽ #write_back Ƥ
ɬפޤ
e
the port to save body of this mail.
.
: each {|line| .... }
line: String
j
ʸʸγƹԤФ뷫֤
body_port.ropen {|f| f.each } ƱǤ
e
iterates for each lines of mail body.
.
: body -> String
: preamble -> String
j
ܥǥ(ʸ)ƤʸȤ֤ޤ
MIME ޥѡȥΤȤ preamble ޤ
֤ͤѹƤ⥪ꥸʥѹޤ
e
the mail body. If the mail is a MIME multipart mail,
this attribute represents "preamble".
.
: parts -> [TMail::Mail]
j
뤬 MIME ޥѡȥλƥѡȤ TMail::Mail Ȥ
ǼƤޤޥѡȥǤʤȤ϶Ǥ
˽ǤɸΥե(ʸ)ѹޤ
ºݤѹ뤿ˤϤΥ֥Ȥ˽ #write_back
Ƥɬפޤ
e
parts of this mail. (valid only if this mail is a MIME multipart mail)
.
: epilogue -> String
j
MIME ޥѡȥǤ epilogue ʸǤ
̾ΥΤȤ϶ʸäƤޤ
˽ǤɸΥե(ʸ)ѹޤ
ºݤѹ뤿ˤϽ #write_back Ƥɬפޤ
e
If the mail was MIME multipart mail, this represent "epilogue" string.
Else, empty string.
.
: multipart?
j
뤬 MIME ޥѡȤΤȤ
Υåɤ Content-Type إåƤǿȽǤޤ
e
true if the message is a multi-part mail.
.
: encoded(eol = "\n", encoding = 'j') -> String
eol: String
encoding: String
j
RFC2822 ˥ɤʸѴޤ
κݡإåιɤ eol ˡإåΥ
ܸʸʸɤ encoding Ѵޤ
encoding "j" (JIS) ưޤ
С 0.9 #to_s #decoded ̾ˤʤäΤǡ
åɤȤϰ㤦Ϥ餭ޤ
e
converts the mail object to a MIME encoded string.
.
: decoded(eol = "\n", encoding = 'e') -> String
: to_s(eol = "\n", encoding = 'e') -> String
eol: String
encoding: String
j
ǥɤ줿ʸѴޤκݡإåι
ɤ eol ˡإåΥܸʸʸɤ
encoding Ѵޤ
С 0.9 ʹߤ #to_s ϤΥåɤ̾ˤʤޤ
e
converts the mail object to a decoded string.
.
: inspect -> String
j
#decoded ̾ǤС 0.9
"#<TMail::Mail port=<StringPort:str=...>>"
Τ褦ʴʷʸԤޤ
e
returns simple string representation like
'"#<TMail::Mail port=<StringPort:str=...>>"'
.
: write_back(eol = "\n", encoding = 'e')
eol: String
encoding: String
j
Τʸ body_port ˽ᤷޤκݡإå
ɤ eol ˡإåܸʸʸɤ encoding
Ѵޤ
e
converts this mail into string and write back to 'body_port',
setting line terminator to EOL.
.
j
=== °ΤΥå
e
=== Property Access Method
.
: date(default = nil) -> Time
: date=(datetime)
datetime: Time
default: Object
j
Date: إåб Time ֥ȡ
˥륿Ѵޤ
e
a Time object of Date: header field.
.
: strftime(format, default = nil) -> String
format: String
default: Object
j
Date: إåɽ줿б Time ֥ȤФ
strftime ƤӤޤDate: إå¸ߤʤ default
֤ޤ
e
is equals to 'date.strftime(format)'.
If date is not exist, this method does nothing and
returns DEFAULT.
.
: to(default = nil) -> [String]
: to=(specs)
specs: String | [String]
default: Object
j
To: ɥ쥹 spec
e
address specs for To: header field.
.
: to_addrs(default = nil) -> [TMail::Address | TMail::AddressGroup]
: to_addrs=(addrs)
addrs: TMail::Address | [TMail::Address]
default: Object
j
To: ɥ쥹
e
adresses which is represented in To: header field.
.
: cc(default = nil) -> [String]
: cc=(specs)
specs: String | [String]
default: Object
j
Cc: ɥ쥹 spec
e
address specs for Cc: header field.
.
: cc_addrs(default = nil) -> [TMail::Address]
: cc_addrs=(addrs)
addrs: TMail::Address | [TMail::Address]
default: Object
j
Cc: ɥ쥹
e
addresses which is represented in Cc: header field.
.
: bcc(default = nil) -> [String]
: bcc=(specs)
specs: String | [String]
default: Object
j
Bcc: ɥ쥹 spec
e
address specs for Bcc: header field.
.
: bcc_addrs(default = nil) -> [TMail::Address]
: bcc_addrs=(addrs)
addrs: TMail::Address | [TMail::Address]
default: Object
j
Bcc: ɥ쥹
e
adresses which is represented in Bcc: header field.
.
: from(default = nil) -> [String]
: from=(specs)
specs: String | [String]
default: Object
j
From: ɥ쥹 spec
e
address specs for From: header field.
.
: from_addrs(default = nil) -> [TMail::Address]
: from_addrs=(addrs)
addrs: TMail::Address | [TMail::Address]
default: Object
j
From: ɥ쥹
e
adresses which is represented in From: header field.
.
: friendly_from(default = nil) -> String
default: Object
j
From: κǽΥɥ쥹 phrase ޤ spec
From: ¸ߤʤȤ default ֤ޤ
e
a "phrase" part or address spec of the first From: address.
.
: reply_to(default = nil) -> [String]
: reply_to=(specs)
specs: String | [String]
default: Object
j
Reply-To: ɥ쥹 spec
e
address specs of Reply-To: header field.
.
: reply_to_addrs(default = nil) -> [TMail::Address]
: reply_to_addrs=(addrs)
addrs: TMail::Address | [TMail::Address]
default: Object
j
Reply-To: ɥ쥹
e
adresses which is represented in Reply-To: header field.
.
: sender(default = nil) -> String
: sender=(spec)
spec: String
j
Sender: ɥ쥹 spec
e
address spec for Sender: header field.
.
: sender_addr(default = nil) -> TMail::Address
: sender_addr=(addr)
addr: TMail::Address
j
Sender: ɥ쥹
e
an address which is represented in Sender: header field.
.
: subject(default = nil) -> String
: subject=(sbj)
sbj: String
j
Subject: ơ
Subject: ¸ߤʤȤ default ֤ޤ
e
the subject of the message.
.
: message_id(default = nil) -> String
: message_id=(id)
id: String
j
Υå ID
e
message ID string.
.
: in_reply_to(default = nil) -> [String]
: in_reply_to=(ids)
ids: String | [String]
j
In-Reply-To: ˴ޤޤå ID Υꥹȡ
e
message IDs of replying mails.
.
: references(default = nil) -> [String]
: references=(ids)
ids: String | [String]
j
References: ˴ޤޤå ID Υꥹȡ
ߤ References: ˤϥå ID ʳ
ޤޤ(RFC2822)
e
message IDs of all referencing (replying) mails.
.
: mime_version(default = nil) -> String
: mime_version=(ver)
ver: String
j
MIME СߤϾ "1.0" Ǥ
إå¸ߤʤ default ֤ޤ
e
MIME version.
If it does not exist, returns the DEFAULT.
.
: set_mime_version(major, minor)
major: Integer
minor: Integer
j
MIME СåȤޤ
e
set MIME version from integers.
.
: content_type(default = nil) -> String
j
ΤΥե륿פʸ㤨 "text/plain"
إå¸ߤʤ default ֤ޤ
e
the content type of the mail message (e.g. "text/plain").
If it does not exist, returns the DEFAULT.
.
: main_type(default = nil) -> String
j
ΤΥᥤ (㡧"text")
˾ʸ줵ޤ
إå¸ߤʤ default ֤ޤ
e
the main content type of the mail message. (e.g. "text")
If it does not exist, returns the DEFAULT.
.
: sub_type(default = nil) -> String
j
ΤΥ֥ (㡧"plain")
˾ʸ줵ޤ
إå¸ߤʤ default ֤ޤ
e
the sub content type of the mail message. (e.g. "plain")
If it does not exist, returns the DEFAULT.
.
: content_type=(ctype)
ctype: String
j
Content-Type Υᥤס֥פ main_sub 饻å
ޤmain_sub 㤨 "text/plain" Τ褦ʷǤʤ
ޤ
e
set content type to STR.
.
: set_content_type(main, sub, params = nil)
main: String
sub: String
params: {String => String}
j
ƥȥפ main/sub; param; param; ... Τ褦ꤷޤ
e
set Content-type: header as "main/sub; param=val; param=val; ...".
.
: type_param(name, default = nil) -> String
name: String
j
Content-Type name ѥ֤ͤޤ
name бͤإåΤΤ¸ߤʤ default
֤ޤ
e
returns the value corresponding to the case-insensitive
NAME of Content-Type parameter.
If it does not exist, returns the DEFAULT.
.
--
# example
mail['Content-Type'] = 'text/plain; charset=iso-2022-jp'
p mail.type_param('charset') # "iso-2022-jp"
--
: multipart? -> true | false
j
Content-Type MIME ޥѡȥǤ뤳Ȥ
Ƥʤп
e
judge if this mail is MIME multi part mail,
by inspecting Content-Type: header field.
.
: transfer_encoding(default = nil) -> String
: transfer_encoding=(encoding)
encoding: String
j
žŬѤǥ (Content-Transfer-Encoding)
'7bit' '8bit' 'Base64' 'Binary' ʤɡ
e
Content-Transfer-Encoding. (e.g. "7bit" "Base64")
.
: disposition(default = nil) -> String
: disposition=(pos)
pos: String
j
Content-Disposition μ (ʸ)֤ͤϾ˾ʸ줵ޤ
name бͤإåΤΤ¸ߤʤ default
֤ޤ
e
Content-Disposition main value (e.g. "attachment").
If it does not exist, returns the DEFAULT.
.
--
# example
mail['Content-Disposition'] = 'attachement; filename="test.rb"'
p mail.disposition # "attachment"
--
: set_content_disposition(pos, params = nil)
pos: String
params: {String => String}
j
disposition ʸȥѥΥϥå夫 Content-Disposition
åȤޤ
e
set content disposition.
.
: disposition_param(key, default = nil) -> String
key: String
j
Content-Disposition ղåѥ name ͤޤ
name бͤإåΤΤ¸ߤʤ default
֤ޤ
e
returns a value corresponding to the Content-Disposition
parameter NAME (e.g. filename).
If it does not exist, returns the DEFAULT.
.
--
# example
mail.disposition_param('filename')
--
: destinations(default = nil) -> [String]
j
ToCcBcc ٤ƤΥɥ쥹ڥåʸ
֤ޤҤȤĤ¸ߤʤ default ֤ޤ
e
all address specs which are contained in To:, Cc: and
Bcc: header fields.
.
: reply_addresses(default = nil) -> [TMail::Address]
j
ֿ٤ɥ쥹ȽǤAddress ֥Ȥ
֤ޤֿ٤ɥ쥹ߤĤʤ
DEFAULT ֤ޤ
e
addresses to we reply to.
.
: error_reply_addresses(default = nil) -> [TMail::Address]
j
顼٤ɥ쥹ȽǤAddress ֥Ȥ
֤ޤ٤ɥ쥹ߤĤʤ default ֤ޤ
e
addresses to use when returning error message.
.
j
=== إåեľѥå
e
=== Direct Header Handling Methods
.
: clear
j
إåƾõޤ
e
clears all header.
.
: keys -> [TMail::HeaderField]
j
إå֤̾ޤ
e
returns an array of contained header names.
.
: [](name) -> TMail::HeaderField
name: String
j
إå̾إå֥Ȥ֤ޤ
e
returns a header field object corresponding to the case-insensitive
key NAME. e.g. mail["To"]
.
: []=(name, field)
name: String
field: TMail::HeaderField
j
name إå field ꤷޤfield ʸ TMail::HeaderField ֥ȤǤ
Received ʤɰΥإåФƤϤˤͿ뤳ȤǤޤ
e
set NAME header field to FIELD.
.
: delete(name)
name: String
j
name إåäޤ
e
deletes header corresponding to case-insensitive key NAME.
.
: delete_if {|name, field| .... }
name: String
field: TMail::HeaderField
j
إå̾ȥإåͿƥ֥åɾʤ餽δϢŤäޤ
e
evaluates block with a name of header and header field object,
and delete the header if block returns true.
.
: each_header {|name, field| .... }
: each_pair {|name, field| .... }
name: String
field: TMail::HeaderField
j
ƤΥإå̾ȥإå֥ȤФ뤯꤫
e
iterates for each header name and its field object.
.
: each_header_name {|name| .... }
: each_key {|name| .... }
name: String
j
ƤΥإå̾Ф뤯꤫
e
iterates for each contained header names.
.
: each_field {|field| .... }
: each_value {|field| .... }
field: TMail::HeaderField
j
ƤΥإå֥ȤФ뤯꤫
e
iterates for each header field objects.
: orderd_each {|name, field| .... }
name: String
field: TMail::HeaderField
j
إåνդ each_header Ǥǽ˻ꤷΤꤷ
֤¤ӡ¾Υإå³ޤʸ
TMail::Mail::FIELD_ORDER ꤷƤ(ܺ٤ϥɤ)
e
iterates for each header field objects, in canonical order.
.
: key?(name)
name: String
j
name إåп
e
returns true if the mail has NAME header.
.
: value?(field)
field: TMail::HeaderField
j
field إå֥Ȥп
e
returns true if the mail has FIELD header field object.
.
: values_at(*names) -> [TMail::HeaderField]
: indexes(*names) -> [TMail::HeaderField]
: indices(*names) -> [TMail::HeaderField]
names: [String]
j
Ƥ names ˤĤ fetch ̤֤ޤ
e
equals to 'names.collect {|k| mail[k] }'.
.
: values -> [TMail::HeaderField]
j
ϿƤƤΥإå֥Ȥ֤ޤ
e
returns an array of all header field object.
.
|