Provides routines to set or retrieve the signature part of a signed message.

author Zaahid Bateson
package MailMimeParser
inherited_from \ZBateson\MailMimeParser\Message\Helper\AbstractHelper

 Methods

Constructor

__construct(\ZBateson\MailMimeParser\Message\Part\Factory\MimePartFactory $mimePartFactory, \ZBateson\MailMimeParser\Message\Part\Factory\UUEncodedPartFactory $uuEncodedPartFactory, \ZBateson\MailMimeParser\Message\Part\Factory\PartBuilderFactory $partBuilderFactory, \ZBateson\MailMimeParser\Message\Helper\GenericHelper $genericHelper, \ZBateson\MailMimeParser\Message\Helper\MultipartHelper $multipartHelper) 
inherited_from \ZBateson\MailMimeParser\Message\Helper\AbstractHelper::__construct()

Parameters

$mimePartFactory

\ZBateson\MailMimeParser\Message\Part\Factory\MimePartFactory

$uuEncodedPartFactory

\ZBateson\MailMimeParser\Message\Part\Factory\UUEncodedPartFactory

$partBuilderFactory

\ZBateson\MailMimeParser\Message\Part\Factory\PartBuilderFactory

$genericHelper

\ZBateson\MailMimeParser\Message\Helper\GenericHelper

$multipartHelper

\ZBateson\MailMimeParser\Message\Helper\MultipartHelper

Constructor

__construct(\ZBateson\MailMimeParser\Message\Part\Factory\MimePartFactory $mimePartFactory, \ZBateson\MailMimeParser\Message\Part\Factory\UUEncodedPartFactory $uuEncodedPartFactory, \ZBateson\MailMimeParser\Message\Part\Factory\PartBuilderFactory $partBuilderFactory) 
Inherited

Parameters

$mimePartFactory

\ZBateson\MailMimeParser\Message\Part\Factory\MimePartFactory

$uuEncodedPartFactory

\ZBateson\MailMimeParser\Message\Part\Factory\UUEncodedPartFactory

$partBuilderFactory

\ZBateson\MailMimeParser\Message\Part\Factory\PartBuilderFactory

Ensures a non-text part comes first in a signed multipart/alternative message as some clients seem to prefer the first content part if the client doesn't understand multipart/signed.

ensureHtmlPartFirstForSignedMessage(\ZBateson\MailMimeParser\Message $message) 

Parameters

$message

\ZBateson\MailMimeParser\Message

Returns the signature part of a multipart/signed message or null.

getSignaturePart(\ZBateson\MailMimeParser\Message $message) : \ZBateson\MailMimeParser\Message\Part\MimePart

The signature part is determined to always be the 2nd child of a multipart/signed message, the first being the 'body'.

Using the 'protocol' parameter of the Content-Type header is unreliable in some instances (for instance a difference of x-pgp-signature versus pgp-signature).

Parameters

$message

\ZBateson\MailMimeParser\Message

Returns

\ZBateson\MailMimeParser\Message\Part\MimePart

Returns a string containing the entire body (content) of a signed message for verification or calculating a signature.

getSignedMessageAsString(\ZBateson\MailMimeParser\Message $message) : string

Non-CRLF new lines are replaced to always be CRLF.

Parameters

$message

\ZBateson\MailMimeParser\Message

Returns

stringor null if the message doesn't have any children

Returns a stream that can be used to read the content part of a signed message, which can be used to sign an email or verify a signature.

getSignedMessageStream(\ZBateson\MailMimeParser\Message $message) : \Psr\Http\Message\StreamInterface

The method simply returns the stream for the first child. No verification of whether the message is in fact a signed message is performed.

Note that unlike getSignedMessageAsString, getSignedMessageStream doesn't replace new lines.

Parameters

$message

\ZBateson\MailMimeParser\Message

Returns

\Psr\Http\Message\StreamInterfaceor null if the message doesn't have any children

Loops over parts of the message and sets the content-transfer-encoding header to quoted-printable for text/* mime parts, and to base64 otherwise for parts that are '8bit' encoded.

overwrite8bitContentEncoding(\ZBateson\MailMimeParser\Message $message) 

Used for multipart/signed messages which doesn't support 8bit transfer encodings.

Parameters

$message

\ZBateson\MailMimeParser\Message

The passed message is set as multipart/signed, and a new part is created below it with content headers, content and children copied from the message.

setMessageAsMultipartSigned(\ZBateson\MailMimeParser\Message $message, string $micalg, string $protocol) 

Parameters

$message

\ZBateson\MailMimeParser\Message

$micalg

string

$protocol

string

Sets the signature of the message to $body, creating a signature part if one doesn't exist.

setSignature(\ZBateson\MailMimeParser\Message $message, string $body) 

Parameters

$message

\ZBateson\MailMimeParser\Message

$body

string

 Properties

 

to create parts for attachments/content

$mimePartFactory : \ZBateson\MailMimeParser\Message\Part\Factory\MimePartFactory

Default

 

to create parts for attachments/content

$partBuilderFactory : \ZBateson\MailMimeParser\Message\Part\Factory\PartBuilderFactory

Default

 

to create parts for attachments

$uuEncodedPartFactory : \ZBateson\MailMimeParser\Message\Part\Factory\UUEncodedPartFactory

Default

 

a GenericHelper instance

$genericHelper : \ZBateson\MailMimeParser\Message\Helper\GenericHelper

Default

 

a MultipartHelper instance

$multipartHelper : \ZBateson\MailMimeParser\Message\Helper\MultipartHelper

Default