Bigloo provides various facilities for handling mails. It provides
facilities for parsing many formats commonly used in composing mails
(quoted printable, vcard, mime types). It also provides facilities for
dealing with mail servers. For that it proposes an abstracted view of
mail servers with two implementations: 
imap and 
maildir.
| 20.1 RFC 2045 -- MIME, Part one
 | 
This section described the functions offered by Bigloo to encode
and decode some of the formats specified in the RFC 2045
http://tools.ietf.org/html/rfc2045.
| 
| quoted-printable-encode string | Bigloo Mail procedure |  
These functions encode/decode a string into and from the| quoted-printable-decode string | Bigloo Mail procedure |  quoted-printableformat.
 Examples:
 
 
 
| (quoted-printable-encode "foo bar") => "foobar=20"
(quoted-printable-decode "foobar=20") => "foo bar"
 |  | 
| 
| quoted-printable-encode-port ip op | Bigloo Mail procedure |  
These functions are similar to| quoted-printable-decode-port ip op [rfc2047] | Bigloo Mail procedure |  quoted-printable-encodeandquoted-printable-decodeexcept that they operate oninput-ports andoutput-ports.
 The function
 quoted-printable-decode-portaccepts an optional
argument:rfc2047. If this argument is#t, then the parsing
stops on the prefix?=, which is a marker in the mail subject
as specified by the RFC 2047, (see http://tools.ietf.org/html/rfc2047)
is found. | 
| 
| mime-content-decode string | Bigloo Mail procedure |  
These two functions parse respectively a| mime-content-decode-port input-port | Bigloo Mail procedure |  stringand aninput-portand return a list of three elements:
 
 Example:a content type,
a content subtype,
options.
 
 
 
| (mime-content-type-decode "text/plain; boundary=Apple-Mail-11") 
  => (text plain ((boundary . Apple-Mail-11)))
 |  | 
| 
| mime-content-disposition-decode string | Bigloo Mail procedure |  
These two functions parse respectively a| mime-content-disposition-decode-port input-port | Bigloo Mail procedure |  stringand aninput-portand return a list describing the content disposition.
 Example:
 
 
 
| (mime-content-disposition-decode "attachment; filename=\"smine.p7s\"")
  => (attachment ((filename . smine.p7s)))
 |  | 
| 
| mime-multipart-decode string boundary [recursive] | Bigloo Mail procedure |  
These two functions parse respectively a| mime-multipart-decode-port input-port boundary [recursive] | Bigloo Mail procedure |  stringand aninput-portand return a list of mime sections.
 If the optional argument
 recursivecontrols whether subparts of
a multipart section must be decoded are not. If therecursiveis#tthen all subparts of the multipart content are decoded. The result
is a fully decoded multipart section. Ifrecursiveis#fsubparts
are not decoded and included in the result as plain strings. | 
 
| 20.2 RFC 2047 -- MIME, Part three
 | 
This section described the function offered by Bigloo to decode
the RFC 2047 encoding used in mail headers 
(see 
http://tools.ietf.org/html/rfc2047).
| 
| rfc2047-decode-port ip op [:charset iso-latin-1] | Bigloo Mail procedure |  
These functions decode mail header fields encoded using the RFC 2047 
specification. The optional argument| rfc2047-decode string [:charset iso-latin-1] | Bigloo Mail procedure |  charsetspecified in which charset
the result should be encoded. The allowed values are:
 
 Example:utf-8iso-latin-1cp-1252
 
 
 
| (rfc2047-decode "Poste =?ISO-8859-1?Q?t=E9l=E9phonique?=")
  => "Poste téléphonique"
(string-for-read (rfc2047-decode "Poste =?ISO-8859-1?Q?t=E9l=E9phonique?=" :charset 'utf8))
  => "Poste t\303\251l\303\251phonique"
 |  | 
 
| 20.3 RFC 2426 -- MIME, Part three
 | 
This section presents the facilities supported by Bigloo for dealing
with 
vcards.
| 
The class| (class vcard
  (version::bstring (default "2.1"))
  (fn (default #f))
  (familyname (default #f))
  (firstname (default #f))
  (face (default #f))
  (url (default #f))
  (org (default #f))
  (emails::pair-nil (default '()))
  (phones::pair-nil (default '()))
  (addresses::pair-nil (default '())))
 |  vardis used to reify in memory a vcard as parsed by
the functionport->vcardandstring->vcard.
 Except
 emails,phones, andaddresses, all fields
are optional. They should be either#for a string.
 
 faceis a flat list of strings.phonesis an alist whose elements are pairs of two strings.addressesis a list composed of:All street values are required and must be provided. The empty string
should be used to denote empty values.the postoffice, a string, 
  a list of strings denoting the street address,
  a string denoting the city,
  a string denoting the region,
  a string denoting the zip code,
  a string denoting the zip country.
 | 
| 
| port->vcard::vcard ip [:charset-encoder] | Bigloo Mail function |  
These two functions parse a vcard to produce a| string->vcard::vcard str [:charset-encoder] | Bigloo Mail function |  vcardinstance.  The optional argumentcharset-encoder, when provided,
must be a function of argument: a string to be decoded. Vcard strings
are UTF-8 encoded. Thecharset-encodercan be used to encode
on-the-fly the strings found in the vcard in a difference encoding. | 
 
| 20.4 RFC 2822 -- Internet Message Format
 | 
This section described the functions offered by Bigloo to encode
and decode some of the formats specified in the RFC 2822
(
http://tools.ietf.org/html/rfc2045). It mainly supports functions
for parsing email headers and for decoding email addresses.
| 
The function| mail-header->list obj | Bigloo Mail procedure |  mail-header->listparses a mail header that can either
be implemented as a string or an input port. It returns a list of fields.
 Example:
 
 
 
| (mail-header->list "Return-Path: <foo.bar@inria.fr>
Received: from eurus.inria.fr ([unix socket])")
  =>
  ((return-path . "<foo.bar@inria.fr>") (received . "from eurus.inria.fr ([unix socket])"))
 |  | 
| 
The function| email-normalize string | Bigloo Mail procedure |  email-normalizeextracts the actual email address
from an email representation.
 Example:
 
| (email-normalize "foo bar <foo.bar@inria.fr>") => "foo.bar@inria.fr"
 |  | 
| 
Extract the name component of an email.| rfc2822-address-display-name string | Bigloo Mail procedure |  
 Example:
 
| (rfc2822-address-display-name "Foo Bar <foo.bar@inria.fr>") => "Foo Bar"
(rfc2822-address-display-name "<foo.bar@inria.fr>") => "foo bar"
 |  | 
 
| 20.5 Mail servers -- imap and maildir
 | 
Bigloo implements the 
imap protocol
(
http://tools.ietf.org/html/rfc3501) and the 
maildir
format. This section presents the API for manipulating them both.
| 
The abstract class| (abstract-class mailbox
  (label::bstring (default "")))
 |  mailboxis the common ancestors to all the
mailbox implementations. It allows the definitions of various generic
functions that deal with mail messages and mail folders. | 
| 
| &mailbox-error | Bigloo Mail class |  
The| (abstract-class &mailbox-error::&error)
 |  &mailbox-erroris the super class of all the errors that
can be raised when accessing mail servers, except the parsing errors
that inherit from the&parse-errorsuper class. | 
| 
Close the mailbox connection.| mailbox-close mailbox | Bigloo Mail procedure |  
 Example:
 
| (let ((mbox (if (network-up?)
                (instantiate::imap (socket ...))
                (instantiate::maildir (path my-local-cache)))))
   (mailbox-close mbox))
 |  | 
| 
Returns a string denoting the separator (commonly| mailbox-separator mailbox | Bigloo Mail procedure |  "or.)
used by themailbox. | 
| 
Returns the prefix of the| mailbox-prefix mailbox | Bigloo Mail procedure |  mailbox, a string or#f. | 
| 
Returns the hostname of the| mailbox-hostname mailbox | Bigloo Mail procedure |  mailbox, a string or#f. | 
| 
Returns a list of strings denoting the folder names of the| mailbox-folders mailbox | Bigloo Mail procedure |  mailbox. | 
| 
Selects one folder of the| mailbox-folder-select! mailbox string | Bigloo Mail procedure |  mailbox. This function is central to 
mailboxes because all messages are referenced relatively to the 
folder selection. All the functions that operates onuidimplicitly access the current folder selection. | 
| 
Unselects the| mailbox-folder-unselect! mailbox | Bigloo Mail procedure |  mailboxcurrent selected folder. | 
| 
Creates a new| mailbox-folder-create! mailbox folder | Bigloo Mail procedure |  folderdenotes by a fully qualified name.
 Example
 
| (mailbox-create! mbox "INBOX.scheme.bigloo")
 |  | 
| 
Deletes an empty| mailbox-folder-delete! mailbox folder | Bigloo Mail procedure |  folder. | 
| 
Renames a folder.| mailbox-folder-rename! mailbox old new | Bigloo Mail procedure |  | 
| 
Moves the| mailbox-folder-move! mailbox folder dest | Bigloo Mail procedure |  folderinto the destination folderdest. | 
| 
| mailbox-subscribe! mailbox folder | Bigloo Mail procedure |  
Subscribe/unsubscribe to a folder. This allows| mailbox-unsubscribe! mailbox folder | Bigloo Mail procedure |  imapservers not
to present the entire list of folders. Only subscribed folders are returned
bymailbox-folders. These functions have no effect onmaildirservers. | 
| 
Returns| mailbox-folder-exists? mailbox folder | Bigloo Mail procedure |  #tif and only iffolderexists inmailbox. Returns#fotherwise. | 
| 
Returns the status of the| mailbox-folder-status mailbox folder | Bigloo Mail procedure |  folder. A status is an alist made of
the number of unseen mail, the uid validity information, the uid next
value, the number of recent messages, and the overall number of messages. | 
| 
Returns the list of UIDs (a list of integers) of the messages contained
in the currently selected folder.| mailbox-folder-uids mailbox | Bigloo Mail procedure |  | 
| 
Returns the list of dates of the messages contained
in the currently selected folder.| mailbox-folder-dates mailbox | Bigloo Mail procedure |  | 
| 
Deletes the messages marked as deleted of the currently selected
folder.| mailbox-folder-delete-messages! mailbox | Bigloo Mail procedure |  | 
| 
Returns the list of headers| mailbox-folder-header-fields mailbox field | Bigloo Mail procedure |  fieldsof the message of the current
folder. | 
| 
Returns the message| mailbox-message mailbox uid | Bigloo Mail procedure |  uidin the current folder. | 
| 
Returns the full path name of the message| mailbox-message-path mailbox uid | Bigloo Mail procedure |  uid. | 
| 
Returns the body of the message| mailbox-message-body mailbox uid [len] | Bigloo Mail procedure |  uid. Iflenis provided, only
returns the firstlencharacters of the body. | 
| 
Returns the header as a string of the message| mailbox-message-header mailbox uid | Bigloo Mail procedure |  uid. | 
| 
Returns the header as an alist of the message| mailbox-message-header-list mailbox uid | Bigloo Mail procedure |  uid. | 
| 
Extracts one field from the message header.| mailbox-message-header-field mailbox uid field | Bigloo Mail procedure |  | 
| 
Returns the size of the message.| mailbox-message-size mailbox uid | Bigloo Mail procedure |  | 
| 
Returns the information relative to the message| mailbox-message-info mailbox uid | Bigloo Mail procedure |  uid. This a list
containing the message identifier, its uid, the message date, the message
size, and the message flags. | 
| 
| mailbox-message-flags mailbox uid | Bigloo Mail procedure |  
Sets/Gets the flags of the message| mailbox-message-flags-set! mailbox uid lst | Bigloo Mail procedure |  uid. This is a list of strings.
Typical flags are:
 
 \Flagged\Answered\Deleted\Seen
 | 
| 
Deletes the message| mailbox-message-delete! mailbox uid | Bigloo Mail procedure |  uid. | 
| 
Moves the message| mailbox-message-move! mailbox uid folder | Bigloo Mail procedure |  uidinto the newfolder(denoted by 
a string). | 
| 
Creates a new message in the| mailbox-message-create! mailbox folder content | Bigloo Mail procedure |  folderwhose content is given the
stringcontent. | 
 
| 
| (class imap::mailbox
  (socket::socket read-only))
 |  
| (define mbox
  (instantiate::maildir
    (label "My Remote Mailbox")
    (socket (imap-login (make-client-socket "imap.inria.fr" 993)
                        "serrano" "XXX"))))
 |  | 
| 
| &imap-parse-error | Bigloo Mail class |  
| (class &imap-parse-error::&io-parse-error)
 |  | 
| 
| &imap-error | Bigloo Mail class |  
| (class &imap-error::&mailbox-error)
 |  | 
| 
Log a user into an imap server. The| imap-login socket user password | Bigloo Mail procedure |  socketmust have been created
first. The argumentuseris a string and denotes the user name.
The argumentpasswordis a string too and it contains the user
password. This function returns as value thesocketit has received.
If the operation fails the function raises a&imap-errorexception.
 Example:
 
 (define mbox
   (imap-login (make-client-socket "imap.inria.fr" 993 :timeout 200000) 
               "serrano" "XXX"))
 
 (print (mailbox-folders mbox))
 | 
| 
Closes an| imap-logout socket | Bigloo Mail procedure |  imapconnection. | 
| 
Returns the list of capabilities supported the| imap-capability socket | Bigloo Mail procedure |  imapserver. | 
 
| 
Example:| (class maildir::mailbox
  (prefix::bstring read-only (default "INBOX"))
  (path::bstring read-only))
 |  
 
 
| (define mbox
  (instantiate::maildir
    (label "My Mailbox")
    (path (make-file-name (getenv "HOME") ".maildir"))))
 (tprint (mailbox-folders mbox))
 |  | 
| 
| &maildir-error | Bigloo Mail class |  
| (class &maildir-error::&mailbox-error)
 |  |