Al manpower
Al manpower

Reputation: 23

Emailing : Gmail change my text in link

I have a big problem with gmail who change my text into a link. I created a email for my company but gmail changed the span "test.com" into a link.

<span class="tt1">Lorem ipsum<br><br>dolor sit amet<br><br>on test.com<br></span>

I don't want a link can u help me?

Thx

Upvotes: 1

Views: 3560

Answers (6)

Rohit Sharma
Rohit Sharma

Reputation: 605

Yes gmail automatically converts the any of the link used in the email template to an anchor tag, even if we have written the link as a plain text in the email template i.e https://example.com

Solution to escape the URL is as follow

 function insertZeroWidthSpace(inputText) {
    const urlRegex = /https?:\/\/[^\s]+/g;
    return inputText.replace(urlRegex, (url) => {
        return url.replace(/\./g, '.&#8203;').replace(/\//g, '/&#8203;');
    });
}

const zeroSpaceText = insertZeroWidthSpace('https://example.com');
console.log(zeroSpaceText); // https://example.com

Here we have inserted a space with 0 width in the URL due to which URL gets broken and due to this reason gmail fails converts that URL to a tag now and URL is shown as plain text in the email template.

Upvotes: 0

James Mitofsky
James Mitofsky

Reputation: 66

Desired Outcome

When writing HTML for emails, represent text which names emails as raw, unformatted text.

Problem

Gmail automatically transforms email addresses into email-creation links (using the mailto: prefix in the href attribute of an a element).

Solution

Add a wrapper around the email which should exist as raw text.

<a
   href="javascript:void(0);"
   style="color:#000; text-decoration:none; cursor:default;"
>
[email protected]
</a>

Upvotes: 0

Al manpower
Al manpower

Reputation: 23

Now test&#46;com doesn't work with gmail, we must use test&#173;.com

Upvotes: 0

Jorgesys
Jorgesys

Reputation: 126523

this issue is related to the Gmail email client.

try using the Html code for "."

<span class="tt1">Lorem ipsum<br><br>dolor sit amet<br><br>on test&#46;com<br></span>

But now i remember, using Gmail client in versions prior to Android 4.0 filter all the links of url and email accounts on the Gmail template.

Other option to disable the link in your email account:

test<span>@</span>email.com

Upvotes: 1

willanderson
willanderson

Reputation: 1568

You can't stop Gmail from turning it into a link, but you can make it a link that goes nowhere and style it to not appear like a link and Gmail will respect your styles. example:

<span class="tt1">Lorem ipsum<br><br>dolor sit amet<br><br>on <a href="" class="no-link">test.com</a><br></span>

add css

.no-link { color:#000; text-decoration:none; cursor:default; }

Upvotes: 3

dlane
dlane

Reputation: 1131

That is something Gmail handles and since it's an email, there isn't much you can do because javascript isn't an option. You could try inserting your URL/domain like this test&#46;com, but that likely won't change the outcome. You might just have to live with it in Gmail. If you can't, I recommend you not include your domain name.

As a side note, Gmail will also auto-link telephone numbers, addresses and even events.

Upvotes: 1

Related Questions