public static function toEmail(Message
$message): Email
{ 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
) {