PHP Class BP_Reply_By_Email_Parser, bp-reply-by-email

Since: 1.0-RC3.
Show file Open project: r-a-y/bp-reply-by-email Class Usage Examples

Public Properties

Property Type Description
$content string The email body content.
$headers array Email headers of the current email.
$is_html boolean Whether the current email uses HTML exclusively.
$querystring string The querystring parsed from the 'From' email address.
$subject string The email subject line.
$user object The WP_User object when successfully parsed.

Public Methods

Method Description
__construct ( array $args = [], $i = 1 ) Constructor.
get_body ( string $body = '', boolean $html = false, boolean $reply = true, integer $i = 1 ) : string | boolean Parses and returns the email body content.
get_header ( array | object $headers, string $key ) : mixed Returns an email header.
get_querystring ( string $address = '' ) : mixed Returns the querystring from an email address.
init ( $args = [], $i = 1 ) : array | object Static initializer.
validate_headers ( array $headers = [], integer $i ) : mixed Checks email headers for auto-submitted / auto-replies.

Protected Methods

Method Description
clear_properties ( ) Clears static properties after reaching the end of parsing.
get_parameters ( ) : mixed Decodes the encoded querystring from {@link BP_Reply_By_Email_Parser::get_querystring()}.
is_new_item ( ) : boolean Check to see if we're parsing a new item (like a new forum topic).

Method Details

__construct() public method

Constructor.
public __construct ( array $args = [], $i = 1 )
$args array { An array of arguments. @type array $headers Email headers. @type string $to_email The 'To' email address. @type string $from_email The 'From' email address. @type string $content The email body content. @type string $subject The email subject line. @type bool $html Whether the email content is HTML or not. }

clear_properties() protected static method

This is to prevent any lingering properties when used in a loop.
protected static clear_properties ( )

get_body() public static method

Parses and returns the email body content.
public static get_body ( string $body = '', boolean $html = false, boolean $reply = true, integer $i = 1 ) : string | boolean
$body string The email body content.
$html boolean Whether the email body is HTML or not. Defaults to false.
$reply boolean Whether the current item is a reply. Defaults to true.
$i integer The current email message number.
return string | boolean

get_header() public static method

If a header includes the user's name, it will return just the email address. eg. r-a-y -> [email protected]
public static get_header ( array | object $headers, string $key ) : mixed
$headers array | object Email headers
$key string The key we want to check against the array.
return mixed Either the email header on success or false on failure

get_parameters() protected static method

Then, extracts the params into an array.
protected static get_parameters ( ) : mixed
return mixed Either an array of params on success or false on failure

get_querystring() public static method

In IMAP mode: [email protected]> -> THEQUERYSTRING In Inbound mode: [email protected] -> THEQUERYSTRING The querystring is encoded by default.
public static get_querystring ( string $address = '' ) : mixed
$address string The email address containing the address tag
return mixed Either the address tag on success or false on failure

init() public static method

Returns an array of the parsed item on success. WP_Error object on failure. For parameters, see constructor.
public static init ( $args = [], $i = 1 ) : array | object
return array | object Array of the parsed item on success. WP_Error object on failure.

is_new_item() protected static method

New items will always have "-new" appended to the querystring. This is what we're checking for. eg. djlkjkdjfkd-new = true jkljd8fujkdjkdf = false
protected static is_new_item ( ) : boolean
return boolean

validate_headers() public static method

Checks email headers for auto-submitted / auto-replies.
public static validate_headers ( array $headers = [], integer $i ) : mixed
$headers array The email headers to check
$i integer The current email message number
return mixed Array of email headers. False if no headers or if the email is junk.

Property Details

$content public static property

The email body content.
public static string $content
return string

$headers public static property

Email headers of the current email.
public static array $headers
return array

$is_html public static property

Whether the current email uses HTML exclusively.
public static bool $is_html
return boolean

$querystring public static property

The querystring parsed from the 'From' email address.
public static string $querystring
return string

$subject public static property

The email subject line.
public static string $subject
return string

$user public static property

The WP_User object when successfully parsed.
public static object $user
return object