mirror of
https://github.com/axllent/mailpit.git
synced 2026-04-26 00:35:51 +03:00
[GH-ISSUE #125] Detect URLs in plain text content, turn them into hyperlinks #82
Labels
No labels
awaiting feedback
bug
docker
documentation
enhancement
github_actions
invalid
pull-request
question
stale
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mailpit#82
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dregad on GitHub (Jun 9, 2023).
Original GitHub issue: https://github.com/axllent/mailpit/issues/125
I'm currently using MailPit to test the user registration and password reset processes in an application.
This sends confirmation e-mails to the user, with a link that they need to click to confirm the action (e.g. validate account or set a new password).
It would be quite convenient if, instead of the link being displayed as plain text, it were automatically turned into an HTML tag so I could just click the link instead of having to select and copy/paste into the browser's address bar.
Example:

Thanks in advance for considering this feature request, and of course for making MailPit - it's great !
@axllent commented on GitHub (Jun 10, 2023):
Hi @dregad. I understand exactly what you are asking, although I must admit I'm rather conflicted about this request. This is a plain text email, and plain text emails do not have clickable links (if they needed to they should have been HTML). Whilst there are some email clients (eg: Gmail) which turn plain text links into clickable links, I fear that by adding this to Mailpit it would give the user the false impression that the link in their email is clickable for everyone, when it most definitely is not.
I will need to think about this some more. I do understand the benefits you describe, so I'll need to weigh up the advantages vs: disadvantages before making a decision.
@dregad commented on GitHub (Jun 10, 2023):
Thanks for your reply and considering my request.
I get your point, maybe this could be controlled by a user preference?
@axllent commented on GitHub (Jun 15, 2023):
I've just released v1.6.20 which contains this feature. It's not perfect, as in it sometimes gets more than just the link if the link is directly followed by a HTML-escaped character, eg:
<http://example.com>then links tohttp://example.com>. I couldn't find a way of correctly eliminating this unfortunately as the>is actually a>which is valid for a link - but for the most part it works as expected. Let me know if this what you were after?@dregad commented on GitHub (Jun 15, 2023):
Many thanks ! I'll test and let you know.
@dregad commented on GitHub (Jun 15, 2023):
I tested various notification e-mails containing links, and confirm the new functionality works great, thanks so much for implementing it !
One small remark, I don't know if you intentionally did not assign a different style to the links (or maybe it's just me not seeing it, being somewhat color-blind), but IMO it would be nice if they actually stood out from regular text to indicate that the URL is clickable, e.g. with blue color.
With regards to the limitation you mentioned, this is really a convenience feature, so if an URL is not properly detected in some corner cases I think it's perfectly acceptable.
That being said, testing the given example
<http://example.com>I noticed it's actually converted to <http://example.com>; (note the trailing;, which is not present in the original message so it's a bit weird to see it added).Maybe that's the trick actually... Detect and ignore trailing HTML entities. But again, I'm fine if you don't fix that.
Illustration from my test, the 2 links in the following raw message body are successfully detected and processed:
becomes

@axllent commented on GitHub (Jun 15, 2023):
Thanks for testing. Yes, I intentionally did not style the links in any way as I did not want to give the impression that this is an HTML email, which again, it is not. Clicking the links is merely a convenience rather than "styling".
As for the tailing
;- I believe this is the issue I was talking about with a slightly greedy link parser. I've just released a fix for that now (v1.6.21) which should hopefully fix that issue.@dregad commented on GitHub (Jun 15, 2023):
OK, fair enough.
Thanks for the follow-up.
Unfortunately I still see the trailing;with 1.6.21 release.[EDIT] Nevermind, it was a browser cache issue. Looking good 🚀
@axllent commented on GitHub (Jun 16, 2023):
LOL, I hadn't noticed your edit and was about to post the same thing - browser cache. That's another thing I have on my list (cache busting), but unrelated to this. Cool, thanks for the feedback. I'll close this issue then.