Problem/Motivation

URL generation regrettably has orthogonal requirements depending on whether content is rendered for the web or for e-mail. For websites it is desirable to generate root relative URLs for all assets and internal links (e.g., when content is reused across multiple domain names). On the other hand for e-mail, all images and links must use absolute URLs.

The core MailManager::doMail() method resolves that dilemma by attempting to convert every root relative e-mail found in a message to an absolute one unconditionally. As a result, most mails using one of the Postoffice Compat mail plugins reusing content from hook_mail() implementations do not need any further processing.

Thus, we need to figure out whether this is a problem which could be solved generically or if it is better to apply specific and targeted fixes.

URL conversion needs to happen before automatic Html2Text conversion (otherwise there is a risk that the text part contains unconverted URLs).

Steps to reproduce

Proposed resolution

For native messages (e.g., mails rendered completely within the context of a BodyRenderer), there might be smarter options than simply copying the MailManager approach. E.g., #3324670: Attach files rendered by the generic file field formatter and #3324667: Embed images rendered by the image field formatter resolved this for attachments and images in a quite specific way.

Text content with embedded links also could be generated using a text format with pathauto applied.

For other cases it might be useful to introduce a Twig Filter. That way site owners and theme designers could modify the output of specific parts of mails to fix special cases.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork postoffice-3325218

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

znerol created an issue. See original summary.

znerol’s picture

Issue summary: View changes