public abstract class EmailHelper

class.emailhelper.php #10

A helper class for various email functions.


static string arrayToList(array $array)

Implodes an associative array or straight array to a comma-separated string

static string base64ContentTransferEncode(string $data, integer $length)

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(string $input, integer $max_length)

Folding an email header field body as required by RFC2822.

  • $input stringheader field body string

  • $max_length integerdefaults to 75


folded output string

static string qEncode(string $input, integer $max_length)

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.

  • $input stringstring to encode

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


$output encoded string

static string qpContentTransferEncode(string $input, integer $max_length)

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.

  • $input stringstring to encode

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


$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