Skip to content

Modify child content type in hook_data #2980

@michaeltalyansky

Description

@michaeltalyansky

I am trying to convert text-only emails to HTML. These emails are Content-Type: multipart/mixed, and text comes as Content-Type: text/plain in the child. I would like to be able to change to Content-Type: text/html, and modify body with add_body_filter.

As far as I can see, hook_data provides me with ability to see the content type in the child, but not change it. In the hook_data_post it is too late.

Describe the solution you'd like
Would it be possible to provide in hook_data a callback with parameters like function (ct, enc, buff, headers) (where headers are the ones from the child, not from the email headers, which is transaction.body.header.get gives), so I can manipulate the headers I need and have them propagated to the child correctly?

Describe alternatives you've considered
So far, I am at a loss about how to do this.

Additional context
Email such as:

-> X-Mailer: swaks v20201014.0 jetmore.org/john/code/swaks/
-> MIME-Version: 1.0
-> Content-Type: multipart/mixed; boundary="----=_MIME_BOUNDARY_000_8111"
->
-> ------=_MIME_BOUNDARY_000_8111
-> Content-Type: text/plain
->
-> aaa
->
-> ------=_MIME_BOUNDARY_000_8111--
->

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions