public abstract class EmailHelper

class.emailhelper.php #10

A helper class for various email functions.

Methods

static string arrayToList()

Implode an array to a comma-separated list

Parameters
  • $arr input array

static void base64ContentTransferEncode()

Content-Transfer-Encoding for attachments

This function will encode attachments according to RFC2045. Line length must not exceed the default (76 characters).

static string fold()

Folding an email header field body as required by RFC2822.

Parameters
  • $input header field body string

  • $max_length defaults to 75

Returns

folded output string

string getMimeType()

Gets mime type of a file.

For email attachments, the mime type is very important. Uses the php 5.3 function (finfo_open), if this function is not found, fallback to a fallback function. Will use application/octet-stream as a fallback when no matches were found.

Returns

MIMEtype

static string qEncode()

Q-encoding of a header field 'text' token or 'word' entity within a 'phrase', according to RFC2047. The output is called an 'encoded-word'; it must not be longer than 75 characters.

This might be achieved with PHP's 'mbstring' functions, but 'mbstring' is a non-default extension.

For simplicity reasons this function encodes every character except upper and lower case letters and decimal digits.

RFC: 'While there is no limit to the length of a multiple-line header field, each line of a header field that contains one or more 'encoded-word's is limited to 76 characters.' The required 'folding' will not be done here, but in another helper function.

This function must be 'multi-byte-sensitive' in a way that it must never scatter a multi-byte character representation across multiple encoded-words. So a 'lookahead' has been implemented, based on the fact that for UTF-8 encoded characters any byte except the first byte will have a leading '10' bit pattern, which means an ASCII value >=128 and <=191.

Parameters
  • $input string to encode

  • $max_length maximum line length (default: 75 chars)

Returns

$output encoded string

static string qpContentTransferEncode()

Quoted-printable encoding of a message body (part), according to RFC2045.

This function handles , , and sequences as 'user relevant' line breaks and encodes them as RFC822 line breaks as required by RFC2045.

Parameters
  • $input string to encode

  • $max_length maximum line length (default: 76 chars)

Returns

$output encoded string

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details