Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Email.php

function Email::generateBody

Generates an AbstractPart based on the raw body of a message.

The most "complex" part generated by this method is when there is text and HTML bodies with related images for the HTML part and some attachments:

multipart/mixed | |------------> multipart/related | | | |------------> multipart/alternative | | | | | ------------> text/plain (with content) | | | | | ------------> text/html (with content) | | | ------------> image/png (with content) | ------------> application/pdf (with content)

1 call to Email::generateBody()
Email::getBody in vendor/symfony/mime/Email.php

File

vendor/symfony/mime/Email.php, line 429

Class

Email
@author Fabien Potencier <fabien@symfony.com>

Namespace

Symfony\Component\Mime

Code

private function generateBody() : AbstractPart {
    if (null !== $this->cachedBody) {
        return $this->cachedBody;
    }
    $this->ensureBodyValid();
    [
        $htmlPart,
        $otherParts,
        $relatedParts,
    ] = $this->prepareParts();
    $part = null === $this->text ? null : new TextPart($this->text, $this->textCharset);
    if (null !== $htmlPart) {
        if (null !== $part) {
            $part = new AlternativePart($part, $htmlPart);
        }
        else {
            $part = $htmlPart;
        }
    }
    if ($relatedParts) {
        $part = new RelatedPart($part, ...$relatedParts);
    }
    if ($otherParts) {
        if ($part) {
            $part = new MixedPart($part, ...$otherParts);
        }
        else {
            $part = new MixedPart(...$otherParts);
        }
    }
    return $this->cachedBody = $part;
}
RSS feed
Powered by Drupal