if ($message instanceof Email
) { return $message;
} // try to convert to a "simple" Email instance
$body =
$message->
getBody();
if ($body instanceof TextPart
) { return self::
createEmailFromTextPart($message,
$body);
} if ($body instanceof AlternativePart
) { return self::
createEmailFromAlternativePart($message,
$body);
} if ($body instanceof RelatedPart
) { return self::
createEmailFromRelatedPart($message,
$body);
} if ($body instanceof MixedPart
) { $parts =
$body->
getParts();
if ($parts[0
] instanceof RelatedPart
) { $email = self::
createEmailFromRelatedPart($message,
$parts[0
]);
} elseif ($parts[0
] instanceof AlternativePart
) {