Score:0

How to have URLs show up as clickable links in Webform submissions sent via Swift Mailer

tr flag

I've got Swift Mailer and Mailsystem installed on a Drupal 8 site I maintain, mostly to handle email submissions from Webforms.

And everything's been working fine — except that just recently we got a Webform submission in which the person had included some URLs in the main message area of the webform (a textarea field). And I was surprised that they did not show up as clickable links in the email — just as plain text. Even though URLs normally convert into links in most emails, even ones just sent from someone's individual email client.

Which means that the site owner, who is not very technical, couldn't figure out what to do with them and I had to explain that he would need to copy and paste the URLs into his browser, which he was not very happy about.

I explored the settings of both the Webform in question and Swift Mailer to see if I could find something that might affect that, but with no luck so far.

Does anyone know how I might be able to get URLs in HTML emails sent by Swift Mailer to show up as clickable links?

Hermann Schwarz avatar
cn flag
Did you try this advices: https://drupal.stackexchange.com/questions/295818/how-to-send-system-mails-in-html-format-with-swift-mailer
DCCweb avatar
tr flag
@HermannSchwarz - I read through that and it's not exactly the same issue. The e-mails are showing up as HTML, and even using the custom swiftmailer.html.twig template I made. But the one thing it's not doing is converting URLs to links... Do you know if Swift Mailer uses any of Drupal's defined text formats? Or is there some other setting somewhere, or some code I can add to the template, that will make it convert URLs to links?
DCCweb avatar
tr flag
Reading through that page again, I saw the bit about setting a text format for Swift Mailer that could at least do some basic things like add line breaks and convert URLs to links, so I tried doing that — created a text format specifically for Email that just had the display HTML as plain text, convert line breaks and convert URLs checked, and set Swift Mailer to use that — but it had no effect. URLs are still not being converted.
Hermann Schwarz avatar
cn flag
1. did you try to use diverse email providers? Maybe email server sanitize your emails from html to plain.
Hermann Schwarz avatar
cn flag
2. Did you check the email source code from the emails?
DCCweb avatar
tr flag
@HermannSchwarz - sorry for the delay in replying, I was moving to a new apartment. The emails are sending in HTML, not plain text, and other HTML features like fonts, spacing and images all work fine. It's just URLs in the textarea not being turned into links. The source code from the emails seems fine — and the phone number and email fields are showing up as links, just not URLs in the main textarea field.
DCCweb avatar
tr flag
Also, it's not using an external email provider, just Sendmail (the site's not very high-traffic, so its email needs are pretty modest).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.