I am just trying to get my multipart emails encoded with base64 and send via swiftmail. Here is the code I have so far:
$message = Swift_Message::newInstance("Email Template Test")
->setBoundary($boundary)
->setFrom(array('[email protected]' => 'Mailer Service'))
->setTo(array("[email protected]","[email protected]"))
->setBody($plaintext)
->addPart($htmlmail,"text/html");
$headers = $message->getHeaders();
$headers->addTextHeader('Content-Transfer-Encoding','base64');
$contenttype = $message->getHeaders()->get('Content-Type');
$contenttype->setValue('multipart/alternative');
As far as I can see from the documentation (which I don't find too clear), The Content-Transfer-Encoding
header is a text header, so i should be able to set it as above. Before this, I ran an output of all the current headers, and Content-Transfer-Encoding
was not listed in there, so It needed to be set. Hence why in the above code I have tried to set it.
The output is fine, I get the emails, they work, but when I view source they are not encoded. I have tried with the same above code but changing $plaintext
to base64_encode($plaintext)
, but just received the encoded message. How is it done>