[GH-ISSUE #125] Detect URLs in plain text content, turn them into hyperlinks #82

Closed
opened 2026-03-15 12:27:37 +03:00 by kerem · 8 comments
Owner

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:
screenshot

Thanks in advance for considering this feature request, and of course for making MailPit - it's great !

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 <a> tag so I could just click the link instead of having to select and copy/paste into the browser's address bar. Example: ![screenshot](https://github.com/axllent/mailpit/assets/449891/c597cd96-1c71-4bc9-96a0-06c222ab5549) Thanks in advance for considering this feature request, and of course for making MailPit - it's great !
kerem closed this issue 2026-03-15 12:27:42 +03:00
Author
Owner

@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.

<!-- gh-comment-id:1585435856 --> @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.
Author
Owner

@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?

<!-- gh-comment-id:1585526312 --> @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?
Author
Owner

@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 to http://example.com>. I couldn't find a way of correctly eliminating this unfortunately as the > is actually a &gt; which is valid for a link - but for the most part it works as expected. Let me know if this what you were after?

<!-- gh-comment-id:1592401478 --> @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 to `http://example.com>`. I couldn't find a way of correctly eliminating this unfortunately as the `>` is actually a `&gt;` which is valid for a link - but for the most part it works as expected. Let me know if this what you were after?
Author
Owner

@dregad commented on GitHub (Jun 15, 2023):

Many thanks ! I'll test and let you know.

<!-- gh-comment-id:1592551833 --> @dregad commented on GitHub (Jun 15, 2023): Many thanks ! I'll test and let you know.
Author
Owner

@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:

A NOTE has been added to this issue.

----------------------------------------------------------------------=20
 (0000596) tadm (administrator) - 2023-06-15 10:46
 http://localhost/mantis/view.php?id=3D3915#c596=20
----------------------------------------------------------------------=20
<http://mantisbt.org>
----------------------------------------------------------------------

becomes
image

<!-- gh-comment-id:1592758765 --> @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>](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: ``` A NOTE has been added to this issue. ----------------------------------------------------------------------=20 (0000596) tadm (administrator) - 2023-06-15 10:46 http://localhost/mantis/view.php?id=3D3915#c596=20 ----------------------------------------------------------------------=20 <http://mantisbt.org> ---------------------------------------------------------------------- ``` becomes ![image](https://github.com/axllent/mailpit/assets/449891/25e675b4-d7ae-4e42-b72b-b929c7716282)
Author
Owner

@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.

<!-- gh-comment-id:1592784980 --> @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.
Author
Owner

@dregad commented on GitHub (Jun 15, 2023):

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".

OK, fair enough.

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.

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 🚀

<!-- gh-comment-id:1593192425 --> @dregad commented on GitHub (Jun 15, 2023): > 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". OK, fair enough. > 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. Thanks for the follow-up. <del>Unfortunately I still see the trailing `;` with 1.6.21 release.</del> [EDIT] Nevermind, it was a browser cache issue. Looking good 🚀
Author
Owner

@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.

<!-- gh-comment-id:1594034419 --> @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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#82
No description provided.