ActiveCampaign / swiftmailer-postmark

The Official Swiftmailer Transport for Postmark.
https://postmarkapp.com
53 stars 28 forks source link

text/plain body is not sent using setBody() #8

Closed z38 closed 7 years ago

z38 commented 7 years ago

During testing, we discovered that a text/plain body is not sent whenever an additional part is added to the message later on.

Example (taken from Swiftmailer docs):

$message = Swift_Message::newInstance()
    ->setSubject('Your subject')
    ->setFrom(array('john@doe.com'))
    ->setTo(array('receiver@domain.org'))
    ->setBody('Here is the message itself', 'text/plain')
    ->addPart('<q>Here is the message itself</q>', 'text/html')
;

At the moment the transport just assumes that the main body of any multipart message is text/html. It seems this issue can not be resolved just yet, as the content type of the body is not exposed: swiftmailer/swiftmailer#736

As a workaround, we use setBody for HTML and addPart for text. The parts get reordered anyway.

atheken commented 7 years ago

Hi @z38 - Thanks for the info. If I'm reading this correctly, there's nothing we can do about this, as it's an issue in how Swiftmailer handles single body parts? If there's something we can do to improve this please feel free to re-open this, and leave a suggestion.

yareckon commented 7 years ago

Added a pull request to at least expose that Body value so you can do your own workaround #939