filter: postie_post_pre

This filter is called just before Postie starts making changes.

Parameters:

  • $parsedEmail

The $parsedEmail parameter is an array describing the email.

You must return the $parsedEmail array from your function.

Example

add_filter('postie_post_pre', 'my_postie_post_pre');

function my_postie_post_pre($email) {
    //Do something
    $email['headers']['subject'] .= ' processed by postie_post_pre';
    return $email;
}

The email value is an associative array containing information about the message. The array will always include the following keys:

  • uid: The UID of the message
  • received: The date the message was received by the server
  • headers: An associative array of mail headers, the keys being the lowercase header names. By default the values are a string, but the following headers are further parsed:
    • received: An array of the Recieved headers
    • to: An array of parsed addressees, each being an associative array in the format:
      • mailbox: The part before the @
      • host: The part after the @
      • personal: The addressee’s name optional
    • cc: An array of parsed addressees, in the same format as to
    • bcc: An associative array of the bcc address, in the same format as to
    • from: An associative array of the from address, in the same format as to
    • sender: An associative array of the sender address, in the same format as to
    • reply-to: An associative array of the address to reply to, in the same format as to
    • content-type: An associative array in the format:
      • value: The main header value
      • fields: An associative array of the ; separated key=value pairs after the main value
    • content-disposition: An associative array in the same format as content-type

And one or more of the following keys:

  • text: The plaintext body
  • html: The HTML body
  • attachment: An array of attachments, each containing:
    • filename: The name of the file
    • mimetype: The mimetype of the file
    • data: The raw contents of the file
  • inline: An array of inline files, each containing:
    • filename: The name of the file
    • mimetype: The mimetype of the file
    • data: The raw contents of the file
  • related: An associative array of related files, such as embedded images, with the key cid:{content-id} and an array value containing:
    • mimetype: The mimetype of the file
    • data: The raw contents of the file
  • verified: If the message contents were verified via an S/MIME certificate – if not verified the smime.p7s file will be listed as an attachment
  • decrypted: If the message contents were decrypted via an S/MIME private key – if not decrypted the smime.p7m file will be listed as an attachment

All values in headers, text and body will have been decoded to UTF-8. Files in the attachment, inline and related array will all retain their original encodings.