I'm logging all emails that are sent from my application. I'm looking for a better way to grab the plaintext version of a SwiftMailer mail if it exists. Currently I'm using the following code in my event listener:
$plainText = optional(
optional(
$event->message->getChildren()
)[0]
)->getBody();
$body = $plainText === null ? $event->message->getBody() : $plainText;
Is there a cleaner way to perform this process if I ever need to repeat this in the future?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire