Long links are shortened

Created on 27 May 2025, about 2 months ago

Problem/Motivation

We implemented symfony_mailer in a project to get styled html mails.
But in those mails long links are shortened now. Not by style but cutting off characters. Our client would like to see the full links in the mails to enable the recipients to mark and copy links in their mails.

Is there a way to do this and prevent shortening long links?
I assume they are cut off in some rendering function?

💬 Support request
Status

Active

Version

1.5

Component

Code

Created by

🇩🇪Germany guido_s Cologne

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @guido_s
  • 🇬🇧United Kingdom adamps
  • 🇩🇪Germany guido_s Cologne

    Found the cause of the issue now.
    Some email bodies where set as ['#type'] = 'processed_text', but had no ['#format'] assigned.
    So the plain_text format was used by default which had the filter 'Convert URLs into Links' active with a 'Maximum Link text length' of 72 characters.

    I fixed this now by creating a new EmailAdjuster and a text format for emails, which will be set if there was no format assigned for processed_text.

    Like this:

    /**
       * {@inheritdoc}
       */
      public function build(EmailInterface $email) {
        $enabled = $this->configuration['enabled'] ?? FALSE;
    
        if (!$enabled) {
          return;
        }
    
        $legacy_message = $email->getParam('legacy_message');
    
        if (isset($legacy_message)) {
          $bodies = $email->getBody();
          foreach ($bodies as &$body) {
            if (isset($body['#type']) && $body['#type'] === 'processed_text' && !isset($body['#format'])) {
              // Check if 'html_email' text format exists before using it.
              if ($this->textFormatExists('html_email')) {
                $body['#format'] = 'html_email';
              }
              else {
                // Fall back to a default format if 'html_email' doesn't exist.
                $body['#format'] = 'plain_text';
              }
            }
          }
          $email->setBody($bodies);
        }
      }
    
  • 🇬🇧United Kingdom adamps

    Thanks for reporting back😃

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024