pop3mail v1.3.1 Pop3mail.Handler View Source

Glue code for received mail to call the parse, decode and store functions

Link to this section Summary

Functions

Check if the mail must be skipped, if not process and store the email

Convert date to a directory name meant for storing the email. Returned date is in format yyyymmdd_hhmmss

Decode body: multipart content, base64 and quoted-printable

Extract the sender name from the email ‘From’ header

Create directory for the email based on date andd subject, save raw email, store header summary and store everything from the body

This function makes sure that the encoding markers are removed and the text decoded

Link to this section Functions

Link to this function check_process_and_store(mail, options) View Source
check_process_and_store(Pop3mail.Handler.Mail.t(), Pop3mail.Handler.Options.t()) ::
  [{:ok, String.t()} | {:error, String.t(), String.t()}]
  | {:skip, [{:header, String.t(), String.t()}]}

Check if the mail must be skipped, if not process and store the email.

It checks if the email has or hasn’t got the Delivered-To header. Mail could be moved from the sent box to the inbox.

mail - Handler.Mail options - Handler.Options

Link to this function convert_date_to_dirname(date_str) View Source
convert_date_to_dirname(String.t()) :: String.t()

Convert date to a directory name meant for storing the email. Returned date is in format yyyymmdd_hhmmss

date_str - string with the date. Must be conform RFC 2822 date format.

Link to this function decode_body_content(header_list, body_content) View Source
decode_body_content([{:header, String.t(), String.t()}], String.t()) :: [
  Pop3mail.Part.t()
]

Decode body: multipart content, base64 and quoted-printable.

Returns a list of Pop3mail.Part’s.

header_list - list with tuples of {:header, header name, header value}.

Link to this function get_sender_name(from) View Source
get_sender_name(String.t()) :: String.t()

Extract the sender name from the email ‘From’ header.

Link to this function process_and_store(mail, options) View Source
process_and_store(Pop3mail.Handler.Mail.t(), Pop3mail.Handler.Options.t()) :: [
  {:ok, String.t()} | {:error, String.t(), String.t()}
]

Create directory for the email based on date andd subject, save raw email, store header summary and store everything from the body.

mail - Handler.Mail options - Handler.Options

Link to this function process_and_store_body(header_list, body_content, dirname) View Source
process_and_store_body(
  [{:header, String.t(), String.t()}],
  String.t(),
  String.t()
) :: [{:ok, String.t()} | {:error, String.t(), String.t()}]

Decode and store body.

header_list - list with tuples of {:header, header name, header value}.

Link to this function remove_encodings(text) View Source
remove_encodings(String.t()) :: String.t()

This function makes sure that the encoding markers are removed and the text decoded.

However, it does not convert to a standard encoding like utf-8 and it also doesn’t mention the encoding types used. What you get is a binary which you might be able to read depending on the character encoding set in your terminal/device/program.