View Source Pop3mail.FileStore (pop3mail v1.5.0)

Store header, messages and attachments on the filesystem.

Summary

Functions

Convert a part's content text from dos-format (with carriage return + linefeed after each line) to unix-format (with just the linefeed).

Construct a filename for an email message.

get line seperator for text files. On windows/dos this is carriage return + linefeed, on other platforms it is just the linefeed.

make directory. Returns created directory name full path.

Remove characters which are undesirable for filesystems (like \ / : * ? " < > | [ ] and control characters)

set default filename in the multipart_part.

store one part of the body.

Functions

Link to this function

dos2unix(multipart_part)

View Source
@spec dos2unix(Pop3mail.Part.t()) :: Pop3mail.Part.t()

Convert a part's content text from dos-format (with carriage return + linefeed after each line) to unix-format (with just the linefeed).

multipart_part - a Pop3mail.Part

Link to this function

get_default_filename(media_type, charset, index)

View Source
@spec get_default_filename(String.t(), String.t(), integer()) :: String.t()

Construct a filename for an email message.

filename will be: 'message' . <charset if not us-ascii> . <extension based on media_type>

The default file extenstion for text/plain is .txt In other cases the last part of the media_type wil be used as extension.

@spec get_line_separator() :: String.t()

get line seperator for text files. On windows/dos this is carriage return + linefeed, on other platforms it is just the linefeed.

Link to this function

mkdir(base_dir, name, unsafe_addition)

View Source
@spec mkdir(String.t(), String.t(), binary()) :: String.t()

make directory. Returns created directory name full path.

directory is base_dir / name - unsafe_addition

unsafe_addition - append this to the directory name. It will be truncated at 45 characters. Unusual characters for the filesystem will be filtered out. If creating the directory with unsafe_addition fails, the directory will be created without it.

Link to this function

remove_unwanted_chars(text, max_chars)

View Source
@spec remove_unwanted_chars(binary(), non_neg_integer()) :: String.t()

Remove characters which are undesirable for filesystems (like \ / : * ? " < > | [ ] and control characters)

Link to this function

set_default_filename(multipart_part)

View Source
@spec set_default_filename(Pop3mail.Part.t()) :: Pop3mail.Part.t()

set default filename in the multipart_part.

Calls FileStore.get_default_filename to get the default filename.

multipart_part - a Pop3mail.Part

Link to this function

store_mail_header(content, filename_prefix, unsafe_addition, dirname)

View Source
@spec store_mail_header(String.t(), String.t(), binary(), String.t()) ::
  {:ok, String.t()} | {:error, atom(), String.t()}

Store mail header.

filename is filename_prefix . unsafe_addition . txt

unsafe_addition - append this to the filename. It will be truncated at 100 characters. Unusual characters for the filesystem will be filtered out. If storing with unsafe_addition fails, the file will be stored without it.

Link to this function

store_part(multipart_part, base_dir)

View Source
@spec store_part(Pop3mail.Part.t(), String.t()) ::
  {:ok, String.t()} | {:error, atom(), String.t()}

store one part of the body.

Text files (media types text/plain, text/html for example) will be converted from dos to unix format on non-windows platforms.

multipart_part - a Pop3mail.Part. Filenames are truncated at 100 characters.

Link to this function

store_raw(mail_content, filename, dirname)

View Source
@spec store_raw(String.t(), String.t(), String.t()) ::
  {:ok, String.t()} | {:error, atom(), String.t()}

store raw email