OpenBuildings / postmark

Postmark transport for Swift Mailer
https://github.com/OpenBuildings/postmark
BSD 3-Clause "New" or "Revised" License
16 stars 8 forks source link

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

Open z38 opened 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.

hkdobrev commented 7 years ago

@z38 Thanks for the issue and looking into potential solution! I'll try to look into it the next few weeks, but please chime in with any suggestions or a pull request if you have an idea how to solve!