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 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340
|
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: RMail::Header</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel=StyleSheet href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript" language="JavaScript">
<!--
function popCode(url) {
window.open(url, "Code",
"resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
//-->
</script>
</head>
<body bgcolor="white">
<table summary="Information on class" width="100%" border="0" cellspacing="0">
<tr class="title-row">
<td class="big-title-font">
<sup><font color="aqua">Class</font></sup> RMail::Header
</td>
<td align="right">
<table summary="layout" cellspacing="0" cellpadding="2">
<tr valign="top">
<td class="small-title-font">In:</td>
<td class="small-title-font">
<a href="../../files/lib/rmail/header_rb.html" class="aqua">
lib/rmail/header.rb
</a>
<br />
</td>
</tr>
<tr>
<td class="small-title-font">Parent:</td>
<td class="small-title-font">
Object
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- banner header -->
<div class="description"><h1>Overview</h1>
<p>
The <a href="Header.html">RMail::Header</a> class supports the creation and
manipulation of RFC2822 mail headers.
</p>
<p>
A mail header is a little bit like a Hash. The fields are keyed by a string
field name. It is also a little bit like an Array, since the fields are in
a specific order. This class provides many of the methods of both the Hash
and Array class. It also includes the Enumerable module.
</p>
<h1>Terminology</h1>
<table>
<tr><td valign="top">header:</td><td>The entire header. Each <a href="Header.html">RMail::Header</a> object is
one mail header.
</td></tr>
<tr><td valign="top">field:</td><td>An element of the header. Fields have a name and a value. For example, the
field "Subject: Hi Mom!" has a name of "Subject" and a
value of "Hi Mom!"
</td></tr>
<tr><td valign="top">name:</td><td>A name of a field. For example: "Subject" or "From".
</td></tr>
<tr><td valign="top">value:</td><td>The value of a field.
</td></tr>
</table>
<h1>Conventions</h1>
<p>
The header’s fields are stored in a particular order. Methods such as
<a href="Header.html#M000058">#each</a> process the headers in this order.
</p>
<p>
When field names or values are added to the object they are frozen. This
helps prevent accidental modification to what is stored in the object.
</p>
</div>
<table summary="Methods" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Methods</td></tr>
</table>
<div class="name-list">
<a href="#M000071">==</a>
<a href="#M000041">[]</a>
<a href="#M000070">[]=</a>
<a href="#M000067">add</a>
<a href="#M000098">add_message_id</a>
<a href="#M000068">add_raw</a>
<a href="#M000103">address_list_assign</a>
<a href="#M000102">address_list_fetch</a>
<a href="#M000093">bcc</a>
<a href="#M000094">bcc=</a>
<a href="#M000091">cc</a>
<a href="#M000092">cc=</a>
<a href="#M000044">clear</a>
<a href="#M000043">clone</a>
<a href="#M000079">content_type</a>
<a href="#M000085">date</a>
<a href="#M000086">date=</a>
<a href="#M000055">delete</a>
<a href="#M000056">delete_at</a>
<a href="#M000057">delete_if</a>
<a href="#M000042">dup</a>
<a href="#M000058">each</a>
<a href="#M000061">each_key</a>
<a href="#M000060">each_name</a>
<a href="#M000059">each_pair</a>
<a href="#M000062">each_value</a>
<a href="#M000063">empty?</a>
<a href="#M000048">fetch</a>
<a href="#M000049">fetch_all</a>
<a href="#M000050">field?</a>
<a href="#M000087">from</a>
<a href="#M000088">from=</a>
<a href="#M000053">has_key?</a>
<a href="#M000052">include?</a>
<a href="#M000054">key?</a>
<a href="#M000066">keys</a>
<a href="#M000046">length</a>
<a href="#M000076">match</a>
<a href="#M000075">match?</a>
<a href="#M000078">mbox_from</a>
<a href="#M000077">mbox_from=</a>
<a href="#M000080">media_type</a>
<a href="#M000051">member?</a>
<a href="#M000097">message_id</a>
<a href="#M000065">names</a>
<a href="#M000040">new</a>
<a href="#M000083">param</a>
<a href="#M000082">params</a>
<a href="#M000101">recipients</a>
<a href="#M000045">replace</a>
<a href="#M000095">reply_to</a>
<a href="#M000096">reply_to=</a>
<a href="#M000064">select</a>
<a href="#M000069">set</a>
<a href="#M000084">set_boundary</a>
<a href="#M000047">size</a>
<a href="#M000099">subject</a>
<a href="#M000100">subject=</a>
<a href="#M000081">subtype</a>
<a href="#M000089">to</a>
<a href="#M000090">to=</a>
<a href="#M000072">to_a</a>
<a href="#M000073">to_s</a>
<a href="#M000074">to_string</a>
</div>
<table summary="Attributes" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Attributes</td></tr>
</table>
<table summary="Attribute details" cellspacing="5">
<tr valign="top">
<td class="attr-name">fields</td>
<td align="center" class="attr-rw"> [RW] </td>
<td></td>
</tr>
</table>
<table summary="Included modules" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Included modules</td></tr>
</table>
<div class="name-list">
<span class="method-name">Enumerable</span>
</div>
<table summary="Method list" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Public Class methods</td></tr>
</table>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000040"></a>
<a href="Header.src/M000040.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000040.html');return false;">
<b>new</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Creates a new empty header object.
</p>
</div>
<table summary="Method list" cellpadding="5" width="100%">
<tr><td class="tablesubtitle">Public Instance methods</td></tr>
</table>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000041"></a>
<a href="Header.src/M000041.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000041.html');return false;">
<b>[]</b>(name_or_index)
</a>
</td></tr>
</table>
<div class="description">
<p>
Return the value of the first matching field of a field name, or nil if
none found. If passed a Fixnum, returns the header indexed by the number.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000042"></a>
<a href="Header.src/M000042.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000042.html');return false;">
<b>dup</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Creates a copy of this header object. A new <a
href="Header.html">RMail::Header</a> is created and the instance data is
copied over. However, the new object will still reference the same strings
held in the original object. Since these strings are frozen, this usually
won’t matter.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000043"></a>
<a href="Header.src/M000043.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000043.html');return false;">
<b>clone</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Creates a complete copy of this header object, including any singleton
methods and strings. The returned object will be a complete and unrelated
duplicate of the original.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000044"></a>
<a href="Header.src/M000044.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000044.html');return false;">
<b>clear</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Delete all fields in this object. Returns self.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000045"></a>
<a href="Header.src/M000045.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000045.html');return false;">
<b>replace</b>(other)
</a>
</td></tr>
</table>
<div class="description">
<p>
Replaces the contents of this header with that of another header object.
Returns self.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000046"></a>
<a href="Header.src/M000046.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000046.html');return false;">
<b>length</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Return the number of fields in this object.
</p>
</div>
<div class="aka">
This method is also aliased as
<a href="Header.html#M000047">size</a>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000047"></a>
<b>size</b>()
</td></tr>
</table>
<div class="description">
<p>
Alias for <a href="Header.html#M000046">#length</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000048"></a>
<a href="Header.src/M000048.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000048.html');return false;">
<b>fetch</b>(name, *rest) {|name| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
Return the value of the first matching field of a given name. If there is
no such field, the value returned by the supplied block is returned. If no
block is passed, the value of <tt>default_value</tt> is returned. If no
<tt>default_value</tt> is specified, an IndexError exception is raised.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000049"></a>
<a href="Header.src/M000049.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000049.html');return false;">
<b>fetch_all</b>(name, *rest) {|name| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns the values of every field named <tt>name</tt>. If there are no such
fields, the value returned by the block is returned. If no block is passed,
the value of <tt>default_value</tt> is returned. If no
<tt>default_value</tt> is specified, an IndexError exception is raised.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000050"></a>
<a href="Header.src/M000050.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000050.html');return false;">
<b>field?</b>(name)
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns true if the message has a field named ‘name’.
</p>
</div>
<div class="aka">
This method is also aliased as
<a href="Header.html#M000051">member?</a>
<a href="Header.html#M000052">include?</a>
<a href="Header.html#M000053">has_key?</a>
<a href="Header.html#M000054">key?</a>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000051"></a>
<b>member?</b>(name)
</td></tr>
</table>
<div class="description">
<p>
Alias for <a href="Header.html#M000050">#field?</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000052"></a>
<b>include?</b>(name)
</td></tr>
</table>
<div class="description">
<p>
Alias for <a href="Header.html#M000050">#field?</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000053"></a>
<b>has_key?</b>(name)
</td></tr>
</table>
<div class="description">
<p>
Alias for <a href="Header.html#M000050">#field?</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000054"></a>
<b>key?</b>(name)
</td></tr>
</table>
<div class="description">
<p>
Alias for <a href="Header.html#M000050">#field?</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000055"></a>
<a href="Header.src/M000055.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000055.html');return false;">
<b>delete</b>(name)
</a>
</td></tr>
</table>
<div class="description">
<p>
Deletes all fields with <tt>name</tt>. Returns self.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000056"></a>
<a href="Header.src/M000056.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000056.html');return false;">
<b>delete_at</b>(index)
</a>
</td></tr>
</table>
<div class="description">
<p>
Deletes the field at the specified index and returns its value.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000057"></a>
<a href="Header.src/M000057.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000057.html');return false;">
<b>delete_if</b>() {|name, value| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
Deletes the field if the passed block returns true. Returns self.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000058"></a>
<a href="Header.src/M000058.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000058.html');return false;">
<b>each</b>() {|name, value| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
Executes block once for each field in the header, passing the key and value
as parameters.
</p>
<p>
Returns self.
</p>
</div>
<div class="aka">
This method is also aliased as
<a href="Header.html#M000059">each_pair</a>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000059"></a>
<b>each_pair</b>()
</td></tr>
</table>
<div class="description">
<p>
Alias for <a href="Header.html#M000058">#each</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000060"></a>
<a href="Header.src/M000060.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000060.html');return false;">
<b>each_name</b>() {|i.name| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
Executes block once for each field in the header, passing the field’s
name as a parameter.
</p>
<p>
Returns self
</p>
</div>
<div class="aka">
This method is also aliased as
<a href="Header.html#M000061">each_key</a>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000061"></a>
<b>each_key</b>()
</td></tr>
</table>
<div class="description">
<p>
Alias for <a href="Header.html#M000060">#each_name</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000062"></a>
<a href="Header.src/M000062.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000062.html');return false;">
<b>each_value</b>() {|i.value| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
Executes block once for each field in the header, passing the field’s
value as a parameter.
</p>
<p>
Returns self
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000063"></a>
<a href="Header.src/M000063.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000063.html');return false;">
<b>empty?</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns true if the header contains no fields
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000064"></a>
<a href="Header.src/M000064.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000064.html');return false;">
<b>select</b>(*names)
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns an array of pairs [ name, value ] for all fields with one of the
names passed.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000065"></a>
<a href="Header.src/M000065.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000065.html');return false;">
<b>names</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns an array consisting of the names of every field in this header.
</p>
</div>
<div class="aka">
This method is also aliased as
<a href="Header.html#M000066">keys</a>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000066"></a>
<b>keys</b>()
</td></tr>
</table>
<div class="description">
<p>
Alias for <a href="Address/List.html#M000125">#names</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000067"></a>
<a href="Header.src/M000067.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000067.html');return false;">
<b>add</b>(name, value, index = nil, params = nil)
</a>
</td></tr>
</table>
<div class="description">
<p>
Add a new field with <tt>name</tt> and <tt>value</tt>. When <tt>index</tt>
is nil (the default if not specified) the line is appended to the header,
otherwise it is inserted at the specified index. E.g. an <tt>index</tt> of
0 will prepend the header line.
</p>
<p>
You can pass additional parameters for the header as a hash table
<tt>params</tt>. Every key of the hash will be the name of the parameter,
and every key’s value the parameter value.
</p>
<p>
E.g.
</p>
<pre>
header.add('Content-Type', 'multipart/mixed', nil,
'boundary' => 'the boundary')
</pre>
<p>
will add this header
</p>
<pre>
Content-Type: multipart/mixed; boundary="the boundary"
</pre>
<p>
Always returns self.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000068"></a>
<a href="Header.src/M000068.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000068.html');return false;">
<b>add_raw</b>(raw)
</a>
</td></tr>
</table>
<div class="description">
<p>
Add a new field as a raw string together with a parsed name/value. This
method is used mainly by the parser and regular programs should stick to <a
href="Header.html#M000067">#add</a>.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000069"></a>
<a href="Header.src/M000069.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000069.html');return false;">
<b>set</b>(name, value, params = nil)
</a>
</td></tr>
</table>
<div class="description">
<p>
First delete any fields with <tt>name</tt>, then append a new field with
<tt>name</tt>, <tt>value</tt>, and <tt>params</tt> as in <a
href="Header.html#M000067">#add</a>.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000070"></a>
<a href="Header.src/M000070.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000070.html');return false;">
<b>[]=</b>(name, value)
</a>
</td></tr>
</table>
<div class="description">
<p>
Append a new field with <tt>name</tt> and <tt>value</tt>. If you want
control of where the field is inserted, see <a
href="Header.html#M000067">#add</a>.
</p>
<p>
Returns <tt>value</tt>.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000071"></a>
<a href="Header.src/M000071.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000071.html');return false;">
<b>==</b>(other)
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns true if the two objects have the same number of fields, in the same
order, with the same values.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000072"></a>
<a href="Header.src/M000072.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000072.html');return false;">
<b>to_a</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns a new array holding one [ name, value ] array per field in the
header.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000073"></a>
<a href="Header.src/M000073.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000073.html');return false;">
<b>to_s</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Converts the header to a string, including any mbox from line. Equivalent
to header.to_string(true).
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000074"></a>
<a href="Header.src/M000074.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000074.html');return false;">
<b>to_string</b>(mbox_from = false)
</a>
</td></tr>
</table>
<div class="description">
<p>
Converts the header to a string. If <tt><a
href="Header.html#M000078">mbox_from</a></tt> is true, then the mbox from
line is also included.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000075"></a>
<a href="Header.src/M000075.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000075.html');return false;">
<b>match?</b>(name, value)
</a>
</td></tr>
</table>
<div class="description">
<p>
Determine if there is any fields that match the given <tt>name</tt> and
<tt>value</tt>.
</p>
<p>
If <tt>name</tt> is a String, all fields of that name are tested. If
<tt>name</tt> is a Regexp the field names are matched against the regexp
(the field names are converted to lower case first). Use the regexp // if
you want to test all field names.
</p>
<p>
If <tt>value</tt> is a String, it is converted to a case insensitive Regexp
that matches the string. Otherwise, it must be a Regexp. Note that the
field value may be folded across many lines, so you should use a multi-line
Regexp. Also consider using a case insensitive Regexp. Use the regexp // if
you want to match all possible field values.
</p>
<p>
Returns true if there is a match, false otherwise.
</p>
<p>
Example:
</p>
<pre>
if h.match?('x-ml-name', /ruby-dev/im)
# do something
end
</pre>
<p>
See also: <a href="Header.html#M000076">#match</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000076"></a>
<a href="Header.src/M000076.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000076.html');return false;">
<b>match</b>(name, value)
</a>
</td></tr>
</table>
<div class="description">
<p>
Find all fields that match the given +name and <tt>value</tt>.
</p>
<p>
If <tt>name</tt> is a String, all fields of that name are tested. If
<tt>name</tt> is a Regexp, the field names are matched against the regexp
(the field names are converted to lower case first). Use the regexp // if
you want to test all field names.
</p>
<p>
If <tt>value</tt> is a String, it is converted to a case insensitive Regexp
that matches the string. Otherwise, it must be a Regexp. Note that the
field value may be folded across many lines, so you may need to use a
multi-line Regexp. Also consider using a case insensitive Regexp. Use the
regexp // if you want to match all possible field values.
</p>
<p>
Returns a new <a href="Header.html">RMail::Header</a> holding all matching
headers.
</p>
<p>
Examples:
</p>
<pre>
received = header.match('Received', //)
destinations = header.match(/^(to|cc|bcc)$/, //)
bigfoot_received = header.match('received',
/from.*by.*bigfoot\.com.*LiteMail/im)
</pre>
<p>
See also: <a href="Header.html#M000075">#match?</a>
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000077"></a>
<a href="Header.src/M000077.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000077.html');return false;">
<b>mbox_from=</b>(value)
</a>
</td></tr>
</table>
<div class="description">
<p>
Sets the "From " line commonly used in the Unix mbox mailbox
format. The <tt>value</tt> supplied should be the entire "From "
line.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000078"></a>
<a href="Header.src/M000078.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000078.html');return false;">
<b>mbox_from</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Gets the "From " line previously set with <a
href="Header.html#M000077">mbox_from=</a>, or nil.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000079"></a>
<a href="Header.src/M000079.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000079.html');return false;">
<b>content_type</b>(default = nil) {|| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
This returns the full content type of this message converted to lower case.
</p>
<p>
If there is no content type header, returns the passed block is executed
and its return value is returned. If no block is passed, the value of the
<tt>default</tt> argument is returned.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000080"></a>
<a href="Header.src/M000080.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000080.html');return false;">
<b>media_type</b>(default = nil) {|| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
This returns the main media type for this message converted to lower case.
This is the first portion of the content type. E.g. a content type of
<tt>text/plain</tt> has a media type of <tt>text</tt>.
</p>
<p>
If there is no content type field, returns the passed block is executed and
its return value is returned. If no block is passed, the value of the
<tt>default</tt> argument is returned.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000081"></a>
<a href="Header.src/M000081.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000081.html');return false;">
<b>subtype</b>(default = nil) {|| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
This returns the media subtype for this message, converted to lower case.
This is the second portion of the content type. E.g. a content type of
<tt>text/plain</tt> has a media subtype of <tt>plain</tt>.
</p>
<p>
If there is no content type field, returns the passed block is executed and
its return value is returned. If no block is passed, the value of the
<tt>default</tt> argument is returned.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000082"></a>
<a href="Header.src/M000082.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000082.html');return false;">
<b>params</b>(field_name, default = nil) {|field_name| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
This returns a hash of parameters. Each key in the hash is the name of the
parameter in lower case and each value in the hash is the unquoted
parameter value. If a parameter has no value, its value in the hash will be
<tt>true</tt>.
</p>
<p>
If the field or parameter does not exist or it is malformed in a way that
makes it impossible to parse, then the passed block is executed and its
return value is returned. If no block is passed, the value of the
<tt>default</tt> argument is returned.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000083"></a>
<a href="Header.src/M000083.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000083.html');return false;">
<b>param</b>(field_name, param_name, default = nil) {|field_name, param_name| ...}
</a>
</td></tr>
</table>
<div class="description">
<p>
This returns the parameter value for the given parameter in the given
field. The value returned is unquoted.
</p>
<p>
If the field or parameter does not exist or it is malformed in a way that
makes it impossible to parse, then the passed block is executed and its
return value is returned. If no block is passed, the value of the
<tt>default</tt> argument is returned.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000084"></a>
<a href="Header.src/M000084.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000084.html');return false;">
<b>set_boundary</b>(boundary)
</a>
</td></tr>
</table>
<div class="description">
<p>
Set the boundary parameter of this message’s Content-Type: field.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000085"></a>
<a href="Header.src/M000085.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000085.html');return false;">
<b>date</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Return the value of the Date: field, parsed into a Time object. Returns nil
if there is no Date: field or the field value could not be parsed.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000086"></a>
<a href="Header.src/M000086.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000086.html');return false;">
<b>date=</b>(time)
</a>
</td></tr>
</table>
<div class="description">
<p>
Deletes any existing Date: fields and appends a new one corresponding to
the given Time object.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000087"></a>
<a href="Header.src/M000087.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000087.html');return false;">
<b>from</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns the value of the From: header as an Array of <a
href="Address.html">RMail::Address</a> objects.
</p>
<p>
See <a href="Header.html#M000102">#address_list_fetch</a> for details on
what is returned.
</p>
<p>
This method does not return a single <a
href="Address.html">RMail::Address</a> value because it is legal to have
multiple addresses in a From: header.
</p>
<p>
This method always returns at least the empty list. So if you are always
only interested in the first from address (most likely the case), you can
safely say:
</p>
<pre>
header.from.first
</pre>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000088"></a>
<a href="Header.src/M000088.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000088.html');return false;">
<b>from=</b>(addresses)
</a>
</td></tr>
</table>
<div class="description">
<p>
Sets the From: field to the supplied address or addresses.
</p>
<p>
See <a href="Header.html#M000103">#address_list_assign</a> for information
on valid values for <tt>addresses</tt>.
</p>
<p>
Note that the From: header usually contains only one address, but it is
legal to have more than one.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000089"></a>
<a href="Header.src/M000089.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000089.html');return false;">
<b>to</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns the value of the To: field as an Array of <a
href="Address.html">RMail::Address</a> objects.
</p>
<p>
See <a href="Header.html#M000102">#address_list_fetch</a> for details on
what is returned.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000090"></a>
<a href="Header.src/M000090.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000090.html');return false;">
<b>to=</b>(addresses)
</a>
</td></tr>
</table>
<div class="description">
<p>
Sets the To: field to the supplied address or addresses.
</p>
<p>
See <a href="Header.html#M000103">#address_list_assign</a> for information
on valid values for <tt>addresses</tt>.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000091"></a>
<a href="Header.src/M000091.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000091.html');return false;">
<b>cc</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns the value of the Cc: field as an Array of <a
href="Address.html">RMail::Address</a> objects.
</p>
<p>
See <a href="Header.html#M000102">#address_list_fetch</a> for details on
what is returned.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000092"></a>
<a href="Header.src/M000092.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000092.html');return false;">
<b>cc=</b>(addresses)
</a>
</td></tr>
</table>
<div class="description">
<p>
Sets the Cc: field to the supplied address or addresses.
</p>
<p>
See <a href="Header.html#M000103">#address_list_assign</a> for information
on valid values for <tt>addresses</tt>.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000093"></a>
<a href="Header.src/M000093.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000093.html');return false;">
<b>bcc</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns the value of the Bcc: field as an Array of <a
href="Address.html">RMail::Address</a> objects.
</p>
<p>
See <a href="Header.html#M000102">#address_list_fetch</a> for details on
what is returned.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000094"></a>
<a href="Header.src/M000094.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000094.html');return false;">
<b>bcc=</b>(addresses)
</a>
</td></tr>
</table>
<div class="description">
<p>
Sets the Bcc: field to the supplied address or addresses.
</p>
<p>
See <a href="Header.html#M000103">#address_list_assign</a> for information
on valid values for <tt>addresses</tt>.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000095"></a>
<a href="Header.src/M000095.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000095.html');return false;">
<b>reply_to</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns the value of the Reply-To: header as an Array of <a
href="Address.html">RMail::Address</a> objects.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000096"></a>
<a href="Header.src/M000096.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000096.html');return false;">
<b>reply_to=</b>(addresses)
</a>
</td></tr>
</table>
<div class="description">
<p>
Sets the Reply-To: field to the supplied address or addresses.
</p>
<p>
See <a href="Header.html#M000103">#address_list_assign</a> for information
on valid values for <tt>addresses</tt>.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000097"></a>
<a href="Header.src/M000097.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000097.html');return false;">
<b>message_id</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns the value of this object’s <a
href="Message.html">Message</a>-Id: field.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000098"></a>
<a href="Header.src/M000098.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000098.html');return false;">
<b>add_message_id</b>(fqdn = nil)
</a>
</td></tr>
</table>
<div class="description">
<p>
Sets the value of this object’s <a
href="Message.html">Message</a>-Id: field to a new random value.
</p>
<p>
If you don’t supply a <tt>fqdn</tt> (fully qualified domain name)
then one will be randomly generated for you. If a valid address exists in
the From: field, its domain will be used as a basis.
</p>
<p>
Part of the randomness in the header is taken from the header itself, so it
is best to call this method after adding other fields to the header —
especially those that make it unique (Subject:, To:, Cc:, etc).
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000099"></a>
<a href="Header.src/M000099.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000099.html');return false;">
<b>subject</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Return the subject of this message.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000100"></a>
<a href="Header.src/M000100.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000100.html');return false;">
<b>subject=</b>(string)
</a>
</td></tr>
</table>
<div class="description">
<p>
Set the subject of this message
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000101"></a>
<a href="Header.src/M000101.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000101.html');return false;">
<b>recipients</b>()
</a>
</td></tr>
</table>
<div class="description">
<p>
Returns an <a href="Address/List.html">RMail::Address::List</a> array
holding all the recipients of this message. This uses the contents of the
To, Cc, and Bcc fields. Duplicate addresses are eliminated.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000102"></a>
<a href="Header.src/M000102.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000102.html');return false;">
<b>address_list_fetch</b>(field_name)
</a>
</td></tr>
</table>
<div class="description">
<p>
Retrieve a given field’s value as an <a
href="Address/List.html">RMail::Address::List</a> of <a
href="Address.html">RMail::Address</a> objects.
</p>
<p>
This method is used to implement many of the convenience methods such as <a
href="Header.html#M000087">#from</a>, <a
href="Header.html#M000089">#to</a>, etc.
</p>
</div>
<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="M000103"></a>
<a href="Header.src/M000103.html" target="Code" class="methodtitle"
onClick="popCode('Header.src/M000103.html');return false;">
<b>address_list_assign</b>(field_name, addresses)
</a>
</td></tr>
</table>
<div class="description">
<p>
Set a given field to a list of supplied <tt>addresses</tt>.
</p>
<p>
The <tt>addresses</tt> may be a String, <a
href="Address.html">RMail::Address</a>, or Array. If a String, it is parsed
for valid email addresses and those found are used. If an <a
href="Address.html">RMail::Address</a>, the result of RMail::Address#format
is used. If an Array, each element of the array must be either a String or
<a href="Address.html">RMail::Address</a> and is treated as above.
</p>
<p>
This method is used to implement many of the convenience methods such as <a
href="Header.html#M000088">#from=</a>, <a
href="Header.html#M000090">#to=</a>, etc.
</p>
</div>
</body>
</html>
|