This file is indexed.

/usr/lib/perl5/Mail/Cclient.pod is in libmail-cclient-perl 1.12-11build2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
=pod

=head1 NAME

Mail::Cclient - Mailbox access via the c-client library API

=head1 SYNOPSIS

=head2 Mail::Cclient API

    use Mail::Cclient;
    $c = Mail::Cclient->new(MAILBOX [, OPTION ...]);

    # Old API deprecated in next versions

    ($envelope, $body) = $c->fetchstructure(MSGNO [, FLAG ...] );
    $hdr = $c->fetchheader(MSGNO [, LINES [, FLAG ...]]);
    $text = $c->fetchtext(MSGNO [, FLAG ...]);
    $text = $c->fetchbody(MSGNO, SECTION [, FLAG ...]);

    $c->fetchflags(SEQUENCE);
    $c->fetchfast(SEQUENCE);

    # New API

    ($envelope, $body) = $c->fetch_structure(MSGNO [, FLAG ...] );
    $msg = $c->fetch_message(MSGNO [, FLAG ...]);
    $hdr = $c->fetch_header(MSGNO, SECTION [, LINES [, FLAG ...]]);
    $text = $c->fetch_text(MSGNO, SECTION [, FLAG ...]);
    $mime = $c->fetch_mime(MSGNO, SECTION [, FLAG ...]);
    $text = $c->fetch_body(MSGNO, SECTION [, FLAG ...]);

    $c->fetch_flags(SEQUENCE);
    $c->fetch_fast(SEQUENCE);

    $elt = $c->elt(MSGNO);

    $c->create(MAILBOX);
    $c->delete(MAILBOX);
    $c->rename(OLDNAME, NEWNAME);
    $c->open(MAILBOX);

    $nmsgs = $c->nmsgs;

    Mail::Cclient::set_callback KEY => CODE, ...
    $c->list(REF, PAT);			# uses "list" callback
    $c->scan(REF, PAT, CONTENTS);
    $c->lsub(REF, PAT);
    $c->subscribe(MAILBOX);
    $c->unsubscribe(MAILBOX);
    $c->status(MAILBOX [, FLAG ...]);	# uses "status" callback

    $c->copy(SEQUENCE, MAILBOX [, FLAG ...]);
    $c->move(SEQUENCE, MAILBOX [, FLAG ...]);
    $c->append(MAILBOX, MESSAGE [, DATE [, FLAGS]);

    $arrayref = $c->sort(
	SORT      => ["crit_1", rev_1, ..., "crit_n", rev_n], # (n <= 7)
	CHARSET   => "MIME character",
	SEARCH    => "string",
	FLAG      => [flag_1, ..., flag_n] / "flag" );
    $c->search(				# uses "searched" callback
	SEARCH    => "string",
	CHARSET   => "MIME character",
	FLAG      => ["flag_1", ..., "flag_n"] / "flag");
    $c->search_msg(MSGNO, CRITERIA [, CHARSET]);
    $arrayref = $c->thread(
	THREADING => "orderedsubject/references",
	CHARSET   => "MIME character",
	SEARCH    => "string",
	FLAG      => "flag");

    $c->ping;
    $c->check;				# uses "log" callback
    $c->expunge;			# uses "expunge" callback
    $uid = $c->uid(MSGNO);
    $msgno = $c->msgno(uid);
    $c->setflag(SEQUENCE, MAILFLAG [, FLAG ...]);
    $c->clearflag(SEQUENCE, MAILFLAG [, FLAG ...]);

    $c->gc( [FLAG, ...] );
    $c->debug;
    $c->nodebug;
    $c->set_sequence(SEQUENCE);
    $c->uid_set_sequence(SEQUENCE);
    $result = $c->parameters(PARAM);
    $c->parameters(PARAM1 => NEWVALUE1 [, PARAM2 => NEWVALUE2 ...]);

    $c->close;

=head2 Mail::Cclient::SMTP API

    $smtp = Mail::Cclient::SMTP->new(
        hostlist => [HOSTS] / "HOST",
        service  => SERVICE,
        port     => PORT,
        options  => ["option_1", ..., "option_n"] / "option");

    $smtp->mail(
        transaction => MAILTYPE,
        defaulthost => HOST,
        filehandle  => FILEHANDLE,
        envelope    => { header => value, ... },
        body        => {HASHREF} );

    $smtp->debug();
    $smtp->nodebug();

    $smtp->close();

=head2 Utility Functions

    Mail::Cclient::rfc822_output(HASHREF);

    $text = Mail::Cclient::rfc822_base64(SOURCE);
    $text = Mail::Cclient::rfc822_binary(SOURCE);
    $text = Mail::Cclient::rfc822_qprint(SOURCE);
    $text = Mail::Cclient::rfc822_8bit(SOURCE);

    $text = Mail::Cclient::utf8_mime2text(SOURCE);

    $str = Mail::Cclient::rfc822_date;

    $str = Mail::Cclient::rfc822_write_address(MAILBOX, HOST, PERSONAL);
    $str = Mail::Cclient::rfc822_parse_adrlist(ADDRESSES, HOST);

=head1 DESCRIPTION

C<Mail::Cclient> gives access to mailboxes in many different formats
(including remote IMAP folders) via the c-client API. The c-client
library is the core library used by Pine and the University of
Washington IMAP daemon (written by Mark Crispin).

The Perl API is mostly taken directly from the underlying c-client
library with minor adjustments in places where Perl provides a more
natural interface. The primary interface is an object oriented one
via the C<Mail::Cclient> class but certain methods implicitly use
callbacks set via the set_callback function.

The c-client library often provides a given piece of functionality by
two different function names: one for simple usage under a name of the
form C<mail_foo> and one with an additional flags arguments under a
name of the form C<mail_foo_full>. The corresponding functionality is
available from the Perl C<Mail::Cclient> class under the single name
C<foo>.

Setting a flag bit such as C<FT_UID> in the c-client API is done in
Perl by appending an extra argument C<"uid"> to the method call.

Arguments to c-client functions which are there only to pass or
receive the length of a string argument or result are not present in
the Perl API since Perl handles them automatically.

Some methods take arguments which refer to a message or messages in a
mailbox. An argument denoted MSGNO is a number that refers to a single
message. Message 1 refers to the first message in the mailbox, unless
the "uid" option is passed as as additional argument in which case the
number refers to the uid of the message. An argument denoted SEQUENCE
refers to a list of messages and is a string such as '1,3,5-9,12'.

Creating a C<Mail::Cclient> object and associating a mailstream with it
is done with the C<"new"> constructor method (whereas the underlying
c-client library uses the C<mail_open> function).

=head1 METHODS

=head2 Mail::Cclient Object Constructor

=over 1

=item new(MAILBOX [, OPTION ...])

Return a new C-Client object. The MAILBOX argument can be anything
accepted by the underlying c-client library. This includes the following
forms

=over 4

=item the special string "INBOX"

This is the driver-dependent INBOX folder.

=item an absolute filename

This specifies a mailbox in the default format
(usually Berkeley format for most default library builds)

=item a string of the form "{host}folder" or "{host/prot}folder"

These refer to an IMAP folder held on host. The "folder"
part can be "INBOX" to reference the distinguished INBOX folder that
the IMAP protocol defines. The username and password required for
logging in to the IMAP server are obtained by using the "login"
callback (q.v.).

=item a string of the form "#driver.foo/bar/baz"

This refers to folder "/bar/baz" which is held in a non-default
mailbox format handled by the c-client driver "foo" (e.g. "mbx").

=back

=back

B<!> The options which can be passed to the C<new> are as follows
(taken almost verbatim from the c-client Internal.doc file):

=over 9

=item debug

Log IMAP protocol telemetry through "debug" callback (q.v.).

=item readonly

Open mailbox read-only.

=item anonymous

Don't use or update a .newsrc file for news.

=item shortcache

Don't cache envelopes or body structures.

=item prototype

Return the "prototype stream" for the driver associated with
this mailbox instead of opening the stream.

=item halfopen

For IMAP and NNTP names, open a connection to the server but
don't open a mailbox.

=item expunge

Silently expunge the oldstream before recycling.

=item secure

Don't do non-secure authentication

=item tryssl

Try SSL first

=back

=head2 Mailstream fields access

B<!> Read-only access to the fields of the underlying mailstream
of a C<Mail::Cclient> object is supplied by the following methods:

=over 11

=item nmsgs

Returns the number of messages in the mailbox.

=item mailbox

Returns the mailbox name.

=item rdonly

Stream is open read-only.

=item anonymous

Stream is open with anonymous access.

=item halfopen

Stream is half-open; it can be reopened or used for functions that
don't need a open mailbox such as $c->create() but no message data
can be fetched.

=item perm_seen, perm_deleted, perm_flagged, perm_answered, perm_draft

The relevant flag can be set permanently.

=item kwd_create

New user flags can be created by referencing them in setflag or
clearflag method calls. This can change during a session (e.g. if
there is a limit).

=item perm_user_flags

Returns a list of the user flags which can be set permanently.

=item recent

Number of recent messages in current mailbox.

=item uid_validity

The UID validity value.

=item uid_last

The highest currently assigned UID in the current mailbox.

=back


=head2 Mailbox Access Methods

B<!> You can use the method

=over 11

=item open(MAILBOX)

to get the mailstream object to open a different mailbox. The cclient
library will try to reuse the same IMAP connection where possible in
the case of IMAP mailboxes but the host part of the mailbox spec must
be given exactly as in the original connection for this to work.

=item list(REF, PAT)

This method returns a list of mailboxes via the list() callback.
REF should normally be just the server specification
("{mailserver:110/imap}"), and PAT (pattern) specifies where in the
mailbox hierarchy to start searching. If you want all mailboxes, pass '*'
for PAT.

There are two special characters you can pass as part of the PAT: "*" and
"%". "*" means to return all mailboxes. If you pass PAT as "*", you will
get a list of the entire mailbox hierarchy. "%" means to return the
current level only. "%" as the PAT parameter will return only the top
level mailboxes; "~/mail/%" on UW_IMAPD will return every mailbox in the
~/mail directory, but none in subfolders of that directory.

=item scan(REF, PAT, CONTENTS)

This method takes a string to search for in the text of the mailbox.

=item lsub(REF, PAT)

This method returns a list of subscribed mailboxes via the lsub() callback.

=item subscribe(MAILBOX)

This method adds the given name to the subscription list.
If unsuccessful, an error message is returned via the log() callback.

=item unsubscribe(MAILBOX)

This method removes the given name from the subscription list.
If unsuccessful, an error message is returned via the log() callback.

=item create(MAILBOX)

This method creates a mailbox with the given name.
If unsuccessful, an error message is returned via the log() callback.

=item delete(MAILBOX)

This method deletes the named mailbox.
If unsuccessful, an error message is returned via the log() callback.

=item rename(OLDNAME, NEWNAME)

This method renames the old mailbox to the new mailbox name.
If unsuccessful, an error message is returned via the log() callback.

=item status(MAILBOX [, FLAG ...])

This method provides status information about MAILBOX. The
information calculated is limited to those mentioned in FLAG
arguments and is returned via the "status" callback (q.v.).
The FLAG arguments possible are precisely those mentioned in
the documentation below for the "status" callback.

=item close()

This method closes the MAIL stream.

=back


=head2 Message Data Fetching Methods

B<!> The following methods provide access to messages themselves: their
headers, structures and the text of their bodies (or parts thereof).

=over 10

=item fetch_fast(SEQUENCE)

This method causes a cache load of all the "fast" information
(internal date, RFC 822 size, and flags) for the given sequence.

=item fetch_flags(SEQUENCE)

This method causes a fetch of the flags for the given sequence.

=item fetch_structure(MSGNO [, FLAG ...] )

This returns the equivalent of what c-client calls an ENVELOPE structure
for message MSGNO. If called in an array context then the equivalent of a
BODY structure is passed as a second return value. The ENVELOPE structure
is in the form of a Perl object of class C<Mail::Cclient::Envelope>. The
BODY structure is in the form of a Perl object of class
C<Mail::Cclient::Body>. See later on for the description of these objects.
The flag "B<uid>" can be passed which makes the MSGNO argument be
interpreted as a message uid.

=item fetch_message(MSGNO [, FLAG ...])

This fetch a complete message (headers + body) from an IMAP server
(a message uid if the flag "B<uid>" is included).

=item fetch_header(MSGNO, SECTION [, LINES [, FLAG ...]])

This returns the message header in RFC822 format (as a single string) of
message MSGNO (which is interpreted as a message uid if the flag "B<uid>"
is included). The SECTION specification is a string of integers delimited
by period (#.#.#...#) and if is specifed then return only the header
section. With no LINES argument, all headers are put into the string. If
an array ref argument is passed then it is taken to be a reference to a
list of header names. Those headers are the ones that are included in the
result, unless the flag "B<not>" is passed in which case all headers are
included except those in the list. The flag "B<internal>" can be passed to
avoid canonicalising the header texts. The flag "B<prefetchtext>" can be
passed to pre-fetch the RFC822.TEXT part of the message at the same time.

=item fetch_mime(MSGNO, SECTION [, FLAG ...])

This returns the message text of message MSGNO (which is interpreted as a
message uid if the flag "B<uid>" is included) or a message text section if
a valid SECTION is provided. The body is returned as a MIME single string.
The SECTION specification is a string of integers delimited by period
(#.#.#...#). The flag "B<internal>" can be passed to avoid canonicalising
of "internal" format to CRLF newlines.

=item fetch_text(MSGNO, SECTION [, FLAG ...])

This returns the body of message MSGNO (a message uid if the flag "B<uid>"
is included) or a message text section if a valid SECTION is provided. The
whole body is returned as a single string with no MIME processing done.
Line endings are canonicalised to CRLF unless the "B<internal>" flag is
included. If the "B<peek>" flag is included then the \Seen flag is not
actively set (though it may already have been set previously, of course).

=item fetch_body(MSGNO, SECTION, [, FLAG ...])

This returns a single (MIME) section of message MSGNO (a message uid if
the flag "B<uid>" is included). The SECTION argument determines which
section is returned and is a string in the form of a dot-separated list of
numbers. See the IMAP specification for details. As an example, a
multipart/mixed MIME message has sections "1", "2", "3" and so on. If
section "3" is multipart/mixed itself, then it has subsections "3.1",
"3.2" and so on. The "B<peek>" and "B<internal>" flags may also be passed
and have the same effect as in C<fetch_text> documented above.

=item uid(MSGNO)

Returns the uid associated with message MSGNO.

=item elt(MSGNO)

This returns the MESSAGECACHE (commonly known as "elt") information
associated with message MSGNO as an object in class Mail::Cclient::Elt.
See below for what such an object contains. B<Important note>: for
this method to be valid, a previous C<fetch_structure> or C<fetch_flags>
B<must> have been called on this message. Otherwise, you are into the
realms of undefined behaviour and at the mercy of the underlying
c-client library.

=back

=head2 Message Status Manipulation Methods

=over 2

=item setflag(SEQUENCE, MAILFLAG [, FLAG ...])

Sets flag MAILFLAG on each message in SEQUENCE (taken to be a sequence of
message uids if the "B<uid>" flag is passed). The "B<silent>" flag causes
the local cache not to be updated.

=item clearflag(SEQUENCE, MAILFLAG [, FLAG ...])

Clears flag MAILFLAG from each message in SEQUENCE (taken to be a sequence
of message uids if the "B<uid>" flag is passed). The "B<silent>" flag
causes the local cache not to be updated.

=back


=head2 Mailbox Searching/Sort/Thread Methods

=over 3

=item search(KEY => VALUE [, KEY1 => VALUE1 ...])

Search for messages satisfying B<SEARCH> keyword value. The "searched"
callback (q.v.) is called for each matching message. The B<SEARCH> keyword
value is a string containing a search specification as defined in item
SEARCH Command (6.4.4.) of RFC2060 (imap2000/docs/rfc/rfc2060.txt). The
B<SEARCH> keyword value is like 'ANSWERED TO "malcolm"' or 'FLAGGED SINCE
1-Feb-1994 NOT FROM "Smith"' (See the searching criteria section for
details). The B<CHARSET> keyword value is a MIME character set to use when
searching strings. The B<FLAG> keyword value can be a array reference or a
string. Flags: "B<uid>" return a message uid's instead of sequence
numbers; "B<searchfree>" return the search program to free storage after
finishing (internal use only); "B<noprefetch>" don't prefetch searched
messages. The B<SEARCH> keyword/value is not optional. All others keywords
are optional.

=item sort(KEY => VALUE [, KEY1 => VALUE1 ...])

Returns an array reference of message numbers sorted by the given pairs of
parameters (KEY => VALUE). The B<SORT> keyword value is a array reference,
and the argument "crit_1", ..., "crit_n", is a string and can be one of
the following: "date", "arrival", "from", "subject", "to", "cc", "size".
The argument rev_1, ... rev_n is 0 or 1 if reverse sorting. The B<CHARSET>
keyword value is a MIME character set to use when sorting strings. The
B<SEARCH> keyword value is a string like, ALL, SEEN, UNSEEN, ANSWERED,
UNANSWERED, FLAGGED, UNFLAGGED, SEARCHED or like SEARCH keyword in search
method and return only messages that meet specified search criteria (See
the searching criteria section for details). The B<FLAG> keyword value can
be a array reference or a string. Flags: "B<uid>" return uid's instead of
sequence numbers; "B<searchfree>" return the search program to free
storage after finishing (internal use only); "B<noprefetch>" don't
prefetch searched messages; "B<sortfree>" return the sort program to free
storage after finishing (internal use only). The B<SORT> keyword/value is
not optional. All others keywords are optional.

=item thread(KEY => VALUE [, KEY1 => VALUE1 ...])

This method returns a array reference of message sequence numbers and/or
lists of lists of message numbers. The B<THREADING> keyword value can take
one of following strings values: "B<orderedsubject>" or "B<references>".
The "B<orderedsubject>" algorithm sorts by subject with a secondary sort
of message date, and then for sets of messages with identical subjects.
The "B<references>" algorithm threads the searched messages by grouping
them together in parent/child relationships based on which messages are
replies to others. The B<CHARSET> keyword value is a MIME character set to
use when searching strings. The B<SEARCH> keyword value accepts a string
ala search() method. The B<FLAG> keyword value is a string. Flags:
"B<uid>" return a message uid's instead of sequence numbers. All keywords
are optional. If you don't use any keyword, in that case the default value
is "B<orderedsubject>".

Example:

ARRAYREF = [2, [3, 6, [4, 23], [44, 7, 96]]

=back


=head2 Miscellaneous Mailbox and Message Methods

The following are miscellaneous methods.

=over 3

=item ping

Checks where the mailstream is still alive: used as a keep-alive and to
check for new mail.

=item check

Performs a (driver-dependent) checkpoint of the mailstream (B<not> a check
for new mail). Information about the checkpoint is passed to the "log"
callback (q.v.).

=item expunge

Expunges all message marked as deleted in the mailbox. Calls the
"expunged" callback (q.v.) on each such message and logging information is
passed to the "log" callback. Decrementing message numbers happens after
each and every message is expunged. As the example in the c-client
documentation for mail_expunge says, if three consecutive messages
starting at msgno 5 are expunged, the "expunged" callback will be called
with a msgno of 5 three times.

=back

B<!> A message may be copied or moved into another mailbox with the
methods C<copy> and C<move>. These methods only allow the destination
mailbox to be of the same type as (and on the same host as) the mailstream
object on which the methods are called.

=over 2

=item copy(MSGNO, MAILBOX [, FLAGS])

This copies message MSGNO (a message uid if the "B<uid>" flag is included)
to mailbox MAILBOX. If the "B<move>" flag is included then the message is
actually moved instead (for compatibility with the CP_MOVE flag of the
underlying c-client C<mail_copy_full> function).

=item move(MSGNO, MAILBOX [, FLAGS])

This moved message MSGNO (a message uid if the "B<uid>" flag is included)
to mailbox MAILBOX.

=back

=over 2

=item append(MAILBOX, MESSAGE [, DATE [, FLAGS])

Append a raw message (MESSAGE is an ordinary string) to MAILBOX, giving it
an optional date and FLAGS (again, simply strings).

=item gc( [FLAG, ...] )

Garbage collects the cache for the mailstream. The FLAG arguments,
"B<elt>", "B<env>", "B<texts>", determine what is garbage collected.

=back

=head2 Utility Methods

=over 7

=item debug

Enables debugging for the mailstream, logged via the "dlog"
callback (q.v.).

=item nodebug

Disables debugging for the mailstream.

=item set_sequence(SEQUENCE)

Sets the sequence bit for each message in SEQUENCE (and turns it off for
all other messages). This has been renamed for Perl from the underlying
c-client function C<mail_sequence> to avoid clashing with the sequence
field member of the mailstream object.

=item uid_set_sequence(SEQUENCE)

Sets the sequence bit for each message referenced by uid in SEQUENCE (and
turns it off for all other messages). This has been renamed for Perl from
the underlying c-client function C<mail_uid_sequence> for consistency with
C<set_sequence> above.

=item search_msg(MSGNO, CRITERIA [, CHARSET])   

It inspects the message B<MSGNO> on that stream to see if it matches the
B<CRITERIA> or not. If it matches, 1 is returned, else 0.

=item msgno(UID)

Returns the msgno associated with message UID.

=item parameters(PARAM [, => NEWVALUE [, PARAM2 => NEWVALUE2 ...]])

With a single argument, gets the current value of parameter PARAM.
With one or more pairs of PARAM => VALUE arguments, sets those PARAM
values to the given new values. PARAM can be one of the following
strings: USERNAME, HOMEDIR, LOCALHOST, SYSINBOX, OPENTIMEOUT, READTIMEOUT,
WRITETIMEOUT, CLOSETIMEOUT, RSHTIMEOUT, SSHTIMEOUT, SSLFAILURE,
MAXLOGINTRIALS, LOOKAHEAD, IMAPPORT, PREFETCH, CLOSEONERROR, POP3PORT,
UIDLOOKAHEAD, MBXPROTECTION, DIRPROTECTION, LOCKPROTECTION, FROMWIDGET,
NEWSACTIVE, NEWSSPOOL, NEWSRC, DISABLEFCNTLLOCK, LOCKEACCESERROR,
LISTMAXLEVEL, ANONYMOUSHOME.

=back

=head2 Mail::Cclient::SMTP Object Constructor 

=over 5

=item new(KEY => VALUE [, KEY1 => VALUE1 ...])

Creates the SMTP object and opens an SMTP connection to a one of the hosts
in the B<hostlist> and if successful returns a stream suitable for use by
the other SMTP methods. The B<hostlist> keyword/value is not optional. All
others keywords are optional.

The following SMTP open options are available:

* debug - Debug protocol negotiations. If "debug" is defined, protocol
telemetry is logged via mm_dlog().

* dsn - DSN notification, none set mean NEVER

* dsn_notify_failure

* dsn_notify_delay

* dsn_notify_success - DSN return full msg vs. header

* dsn_return_full

* 8bitmime - 8-bit MIME requested

* secure - Don't do non-secure authentication

* tryssl - Try SSL first

* tryalt - Old name for tryssl

=item mail(OPTION => VALUE, ...)

The options which can be passed to the mail are as follows

=over 5

=item transaction => "string value"

This option set the type of SMTP transaction (one of "MAIL", "SEND", 
"SAML", or "SOML") to deliver the specified message.

=item defaulthost => "string value"

Default host name if an address lacks an @host.

=item filehandle => HANDLE

Filehandle to write output message described with the given envelope
and body.

=item envelope => { header => value, ... }

The following headers are available for envelope message:

from, to, cc, bcc, sender, reply_to, return_path, in_reply_to, message_id, 
subject, remail, date, newsgroups, followup_to, references

=item body => { option => value, ... }

The following fields are available for body message:

=over 12

=item content_type

The content_type is a string like "type/subtype". Type is the MIME type of
the message. For example, text, multipart, message, application, audio,
image, video, model, ...

Subtype is the MIME subtype of the message. For example, PLAIN, HTML,
MIXED, RELATED, or ALTERNATIVE.

=item encoding

Encoding of a single part message or the body of a multipart message. The
MIME encoding can be one of the following strings: 7bit, 8bit, binary,
base64, quoted-printable.

=item part => [{part1}, {part2}, ...]

For MIME type multipart messages

=item disposition => [{type => "inline/attachment"}, [parameter]]

The content disposition of the body: a reference to a list consisting of
the disposition type followed by a (possibly empty) list of parameter.

=item parameter => [{attribute => attr_val1 }, {value => val_val1}, ...]

List of hash references.

=item description

The MIME description of the body part.

=item language => ["en", "pt", ...]

body language list reference (header "Content-Language: ").

=item location

body content URI (header "Content-Location: ").

=item id

The message ID (header "Content-ID: ")

=item md5

The MD5 checksum of the body (header "Content-MD5: ").

=item data

Message data of part body.

=item path

Pathname of file to attach. For example "/usr/local/images/image.jpg". If
you use data in hash then don't use path.

=back

=back

=item close()

This method closes the SMTP stream.

=item debug

This method enables SMTP protocol telemetry logging for this stream. All
SMTP protocol operations are passed to the application via the dlog()
facility.

=item nodebug

This method disables SMTP protocol telemetry

=back

=head1 UTILITY FUNCTIONS (RFC 822 Support Functions)

The following are utility functions (not methods).

=over 9

=item Mail::Cclient::rfc822_base64(SOURCE)

Returns the SOURCE text converted to base64 format.

=item Mail::Cclient::rfc822_binary(SOURCE)

Convert binary contents to base64

=item Mail::Cclient::rfc822_qprint(SOURCE)

Returns the SOURCE text converted to quoted printable format.

=item Mail::Cclient::rfc822_8bit(SOURCE)
    
Convert 8bit contents to quoted-printable text

=item Mail::Cclient::utf8_mime2text(SOURCE)

Returns the MIME-2 SOURCE text converted to UTF-8.

=item Mail::Cclient::rfc822_date()

Returns the current date in RFC822 format.

=item Mail::Cclient::rfc822_write_address(MAILBOX, HOST, PERSONAL)

This function return an RFC 822 format address string based on the 
information from MAILBOX, HOST and PERSONAL.

=item Mail::Cclient::rfc822_parse_adrlist(ADDRESSES, HOST)

This function parses the string of ADDRESSES into an address list array
ref. Any addresses missing a host name are have the host name defaulted
from the HOST argument. Any parsing errors are noted via the log()
callback.

=item Mail::Cclient::rfc822_output(HASHREF)

This function writes the message described with the given envelope and
body. The options which can be passed to the rfc822_output are as follows:

=over 4

=item defaulthost => "string"

=item filehandle => HANDLE

=item envelope => { header => value, ... }

=item body => { option => value, ... }

=back

=back


=head1 CALLBACKS

Certain methods mentioned above use callbacks to pass or receive extra
information. Each callback has a particular name (e.g. "log", "dlog",
"list", "login") and can be associated with a particular piece of Perl
code via the C<Mail::Cclient::set_callback> function (available for export
by the C<Mail::Cclient> class). The C<set_callback> function takes pairs
of arguments NAME, CODE for setting callback NAME to be the given CODE, a
subroutine reference. The only callback which is required to be set and
the only callback whose return value matters is the "login" callback (only
used when the "new" method constructs an IMAP mailstream). Apart from that
case, callbacks which have not been set are ignored. A callback set to
undef is also ignored.

=over 15

=item searched(STREAM, MSGNO)

This callback is invoked for each message number satifying the CRITERIA of
the "search" method, defined above.

=item exists(STREAM, MSGNO)

=item expunged(STREAM, MSGNO)

=item flags(STREAM, MSGNO)

=item notify(STREAM, STRING, ERRFLAG)

=item list(STREAM, DELIMITER, MAILBOX [, ATTR ...])

=item lsub(STREAM, DELIMITER, MAILBOX [, ATTR ...])

=item status(STREAM, MAILBOX, [, ATTR, VALUE] ...)

Attribute values passed can be "messages", "recent", "unseen",
"uidvalidity", "uidnext".

=item log(STRING, ERRFLAG)

=item dlog(STRING)

=item fatal(STRING)

=item login(NETMBXINFO, TRIAL)

The "login" callback is invoked when the c-client library is opening an
IMAP mailstream and needs to find out the username and password required.
This callback must return precisely two values in the form (USERNAME,
PASSWORD). TRIAL is the number of the current login attempt (starting at
1). NETMBXINFO is a hash reference with the following keys:

=over 11

=item host

The hostname of the IMAP server.

=item user

The username requested.

=item mailbox

The mailbox name requested.

=item service

=item port

=item anoflag

Set to 1 if anonymous access has been requested otherwise this key is not
created at all.

=item dbgflag

Set to 1 if debugging access has been requested otherwise this key is not
created at all.

=item secflag

Set to 1 if secure access has been requested otherwise this key is not
created at all.

=item sslflag

=item trysslflag

=item novalidate

=back

=item critical(STREAM)

=item nocritical(STREAM)

=item diskerror(STREAM, ERRCODE, SERIOUS)

=back


=head1 ENVELOPES, BODIES, ADDRESSES and ELTS

The results of the C<fetch_structure> and C<elt> methods involve objects
in the classes C<Mail::Cclient::Envelope>, C<Mail::Cclient::Body>,
C<Mail::Cclient::Address> and C<Mail::Cclient::Elt>. These will be
referred to as Envelope, Body, Address and Elt objects respectively. These
objects are all "read-only" and only have methods for picking out
particular fields.


=head2 Address objects

An Address object represents a single email address and has the following
fields, available as methods or, if Perl 5.005 or later is being used, as
pseudo-hash keys.

=over 5

=item personal

The personal phrase of the address (i.e. the part contained in parentheses
or outside the angle brackets).

=item adl

The at-domain-list or source route (not usually used).

=item mailbox

The mailbox name (i.e. the part before the @ which is usually a username
or suchlike).

=item host

The hostname (i.e. the part after the @).

=item error

Only set if the address has delivery errors when C<smtp_mail> is called.
Since that function hasn't been implemented in the Perl module yet, this
isn't any use.

=back


=head2 Envelope objects

An Envelope object represents a structured form of the header of a
message. It has the following fields, available as methods or, if Perl
5.005 or later is being used, as pseudo-hash keys.

=over 2

=item remail, date, subject, in_reply_to, message_id, newsgroups,
followup_to, references,

These are all strings.

=item return_path, from, sender, reply_to, to, cc, bcc

These are all references to lists which contain one or more Address
objects.

=back


=head2 Body objects

A Body object represents the structure of a message body (not its
contents).It has the following fields, available as methods or, if Perl
5.005 or later is being used, as pseudo-hash keys.

=over 12

=item type

The MIME type (as a string) of the message (currently in uppercase as
returned from the c-client library). For example, "TEXT" or "MULTIPART".

=item encoding

The MIME encoding (as a string) of the message.

=item subtype

The MIME subtype (as a string) of the message. For example, "PLAIN",
"HTML" or "MIXED".

=item parameter

A reference to a list of MIME parameter key/value pairs.

=item id

The message ID.

=item description

The MIME description of the body part.

=item nested

If (and only if) the body is of MIME type multipart, then this field is a
reference to a list of Body objects, each representing one of the sub
parts of the message. If (and only if) the body is of MIME type
message/rfc822, then this field is a reference to a list of the form
(ENVELOPE, BODY) which are, respectively, the Body and Envelope objects
referring to the encapsulated message. If the message is not of MIME type
multipart or message/rfc822 then this field is undef.

=item lines

The size in lines of the body.

=item bytes

The size in bytes of the body.

=item md5

The MD5 checksum of the body.

=item disposition

The content disposition of the body: a reference to a list consisting of
the disposition type followed by a (possibly empty) list of parameter
key/value pairs.

=back


=head2 Elt objects

These have fields containing flag information for a given message, along
with internal date information and the RFC822 message size.

=over 4

=item msgno

The message number.

=item date

This contains the internal date information (spread about a series of
bitfields in the underlying c-client library C structure) in the form of a
string:

    yyyy-mm-dd hh:mm:ss [+-]hhmm

=item flags

A reference to a list of flags associated with the message. The flags are
in the forms of their RFC2060 names (e.g. \Deleted, \Seen) for official
flags and the user-chosen name for user-defined flags.

=item rfc822_size

The RFC822 size of the message.

=item imapdate

This contains the internal date information (spread about a series of
bitfields in the underlying c-client library C structure) in the form of a
string:

    dd-mmm-yyyy hh:mm:ss [+-]hhmm

This form is needed by IMAP servers.

=back


=head1 SEARCHING CRITERIA

Searching criteria consist of one or more search keys. When multiple keys
are specified, the result is the intersection (AND function) of all the
messages that match those keys. A search key can also be a parenthesized
list of one or more search keys. In all search keys that use strings, a
message matches the key if the string is a substring of the field. The
matching is case-insensitive.

The defined search keys are as follows.

=over 36

=item <message set>

Messages with message sequence numbers corresponding to the specified
message sequence number set.

=item ALL

All messages in the mailbox; the default initial key for ANDing.

=item ANSWERED

Messages with the B<\Answered> flag set.

=item BCC <string>

Messages that contain the specified string in the envelope structure's BCC
field.

=item BEFORE <date>

Messages whose internal date is earlier than the specified date.

=item BODY <string>

Messages that contain the specified string in the body of the message.

=item CC <string>

Messages that contain the specified string in the envelope structure's CC
field.

=item DELETED

Messages with the B<\Deleted> flag set.

=item DRAFT

Messages with the B<\Draft> flag set.

=item FLAGGED

Messages with the B<\Flagged> flag set.

=item FROM <string>

Messages that contain the specified string in the envelope structure's
FROM field.

=item HEADER <field-name> <string>

Messages that have a header with the specified field-name (as defined in
[RFC-822]) and that contains the specified string in the [RFC-822]
field-body.

=item KEYWORD <flag>

Messages with the specified keyword set.

=item LARGER <n>

Messages with an [RFC-822] size larger than the specified number of
octets.

=item NEW

Messages that have the B<\Recent> flag set but not the B<\Seen> flag. This
is functionally equivalent to "(RECENT UNSEEN)".

=item NOT <search-key>

Messages that do not match the specified search key.

=item OLD

Messages that do not have the B<\Recent> flag set. This is functionally
equivalent to "NOT RECENT" (as opposed to "NOT NEW").

=item ON <date>

Messages whose internal date is within the specified date.

=item OR <search-key1> <search-key2>

Messages that match either search key.

=item RECENT

Messages that have the B<\Recent> flag set.

=item SEEN

Messages that have the B<\Seen> flag set.

=item SENTBEFORE <date>

Messages whose [RFC-822] Date: header is earlier than the specified date.

=item SENTON <date>

Messages whose [RFC-822] Date: header is within the specified date.

=item SENTSINCE <date>

Messages whose [RFC-822] Date: header is within or later than the
specified date.

=item SINCE <date>

Messages whose internal date is within or later than the specified date.

=item SMALLER <n>

Messages with an [RFC-822] size smaller than the specified number of
octets.

=item SUBJECT <string>

Messages that contain the specified string in the envelope structure's
SUBJECT field.

=item TEXT <string>

Messages that contain the specified string in the header or body of the
message.

=item TO <string>

Messages that contain the specified string in the envelope structure's TO
field.

=item UID <message set>

Messages with unique identifiers corresponding to the specified unique
identifier set.

=item UNANSWERED

Messages that do not have the B<\Answered> flag set.

=item UNDELETED

Messages that do not have the B<\Deleted> flag set.

=item UNDRAFT

Messages that do not have the B<\Draft> flag set.

=item UNFLAGGED

Messages that do not have the B<\Flagged> flag set.

=item UNKEYWORD <flag>

Messages that do not have the specified keyword set.

=item UNSEEN

Messages that do not have the B<\Seen> flag set.

=back

=head1 CAVEATS

This CAVEATS section was contributed by Bruce Gingery <bgingery@gtcs.com>.

The Mail::Cclient::B<mailbox> method returns the actual full path opened,
which may not give an accurate string comparison with the mailbox that was
requested to be opened.  This is especially true with remote mailboxes.

The C-Client library is VERY intolerant of logic errors, and does not
automatically garbage collect.  Use the C<gc> method as it makes sense for
your application.

Some POP3 servers B<delete and expunge WITHOUT instruction to do so.> This
is not a malfunction in either the C-Client code nor the Mail::Cclient
modules.

The C<open> method can be used to extend a C<halfopen> connection (e.g.
use the same c-client instance to read a mailbox that was previously
halfopened for a list of mailboxes. This may or may not be a good idea,
depending upon your needs.  It does, however, eliminate the problem of
opening multiple connections, such as has been noted in Netscape 4.x mail
handling, and which plagues some servers badly.  It may be better,
however, to C<close> the connection used for C<list>, and re-instantiate
to process the mailbox.

C-Client may not support headers you need for send. Note that other
modules I<can> be used in place of sending with the c-client. These
include Net::SMTP, local invocation of piped sendmail (or other E-mail
insertion software), or sendto: URLs under libwww POST.

C<Elt> information for remote mailboxes is server dependent, as well. You 
may or may not get rfc822_size in elt returns, for example.

Multiple c-client instances open simultaneously may not work as expected.

=head1 AUTHOR

Malcolm Beattie, mbeattie@sable.ox.ac.uk.

Maintained by Henrique Dias, hdias@aesbuc.pt.

=head1 VERSION

version 1.12

=head1 SEE ALSO

perl(1) IMAP::Admin Mail::Send

=cut