/** * Set plain text for $this->message, replacing if necessary * * @return null|string */ protected function setMessagePlainText() { if ($this->tokenizationEnabled && $this->plainTextSet) { // No need to find and replace since tokenization happens at the transport level return; } if ($this->plainTextSet) { $children = (array) $this->message->getChildren(); /** @var \Swift_Mime_MimeEntity $child */ foreach ($children as $child) { $childType = $child->getContentType(); if ($childType == 'text/plain' && $child instanceof \Swift_MimePart) { $child->setBody($this->plainText); break; } } } else { $this->message->addPart($this->plainText, 'text/plain'); $this->plainTextSet = true; } }