mardi 1 mai 2018

Get plaintext email from event

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?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Fw8uYy
via IFTTT

Aucun commentaire:

Enregistrer un commentaire