Did you know ... Search Documentation:
Pack mail_standards -- prolog/imf.pl
PublicShow source

This modules gives DCGs for using with the Internet Message Format(IMF) specified on the RFC 5322.

Unsupported

Line characters 998/78 limits specified on section 2.1.1 are not supported in this DCG implementation.

Section 4 corresponding for the obsolete syntax is currently unsupported.

MIME support is not provided, instead you can use mime_pack/3 from library(http/mimepack) (HTTP-support package) for creating a MIME message and mime_parse/2 from the library(mime) (C-library package).

Common Characters

For characters like WSP, CR, LF, etc. they are defined at Appendix B.1 at the RFC5234 ABNF specification.

author
- Gimenez, Christian
license
- GPLv3
 message(?Message)//
A message format.
See also
- IMF Section 2
 message_str(?Message)//
Same as message//1 but returning Strings instead of codes.
 header(?LstHeaders)//
All the headers fields.
Arguments:
LstHeaders- A list of field/2 terms, like field(FieldName, FieldBody).
 header_str(?LstHeaders)//
Same as header//1 but returning Strings instead of codes.
 header_field(?FieldName, ?FieldBody)//
See also
- IMF Section 2.2
 field_body(?Body)//
See also
- IMF Section 3
- IMF Section 4
 body(?Str)//
The body of the IMF. No MIME processing!
See also
- IMF Section 2.3
 folded_string(?Str)//
A folded string is a string wich can be writed into various lines. For example:
Folding text
  like this
  and this

Each CRLF is translated into space:

Folding text like this and this
See also
- IMF Section 2.2.3
- IMF Section 3.2.2
 imf_parse_file(+Path:atom, -Message:pred)
Read the file and parse it returning a Prolog predicate with all the information.

Message Output

Example of message/2:

message(
    header([
        field("From", "from@fromhost.com"),
        field("To", "to@tohost.com"),
        field("Subject","Subject part"),
        field("Date","Wed,  9 Dec 2015 17:27:50 -0300 (ART)")]),
    body("Hi world"))
Arguments:
Path- The file path.
Message- A message/2 predicate with the mail header/1 and body/1 information.
 date_time(-Date:pred)//
Return a date predicate from a string header's value. Useful for the Date header.

The syntax is explained in section 3.3 of the IMF standard.

See also
- IMF Section 3.3