Problem/Motivation
Postmarks sends out the mails, but without respecting the line-breaks.
Line-breaks are automatically added after some signs (I think from postmark itself, because postmark gets no line-breaks delivered?)

Proposed resolution
I think there is some problem how postmarks gets the text it should send.

--

Also used mimemail https://www.drupal.org/project/mimemail in between (drupal > mimemail > postmark) but then extra header informations are also visible in the sent mail…

I use the latest d8 dev version installed via composer.
Any postmark setting I have missed?

thx
Nico

Comments

Grienauer created an issue. See original summary.

john.oltman’s picture

See if setting $message['headers']['Content-Type'] to 'text/plain' helps.

vierlex’s picture

I figured out a bit:

postmark/src/Plugin/Mail/PostmarkMail.php::118

    if (isset($message['plain'])) {
      $postmark_message['text'] = $message['plain'];
    }
    else {
      $converter = new Html2Text($message['body']);
      $postmark_message['text'] = $converter->getText();
    }

If the $message already is formatted as plain/text,
this Html2Text will effectively destroy any "\n" line breaks.

I dont see how $message['plain'] is filled anywhere, except doing it manually in a hook_mail_alter()
(This is our Quickfix for now since we only need to send plain/text mails)

Also in the same class inside the format function at ::89

$format = $this->config->get('format_filter');
    if (!empty($format)) {
      $message['body'] = check_markup($message['body'], $format, $message['langcode']);
    }

There is no format_filter inside the postmark.settings.yml nor is there a Interface for it.

I guess this is a good place to check if this email is html or plain/text and set the
$message['body'] and $message['plain'] accordingly. Either using that format_filter config setting
or using the $message['headers']['Content-Type']?
Question is where it is set anyway..

Also setting anything inside $message['headers'] are not passed along to the postmark client library.

steffenr’s picture

Maybe we should add an alteration hook to the module. In this case, we can control the $postmark_message variable / mail created for Postmark service.