Link to home
Start Free TrialLog in
Avatar of DavidRMason
DavidRMason

asked on

How do I create a hyperlink that works on all email systems?

I am developing a web site using PHP and mySQL and at one point I need to send the user a link to reset their password.

In my design, the e-mail is sent using HTML and the link is programmed using the obvious <a href="http://... &c tag.

This works fine on most systems; however, users with iPad and iPhone report that nothing happens when they click the link, although other links that others send them are working.

When I ask to see the links that are working it appears that they are written in plain text and that the link is actually being generated on the fly by Apple's e-mail reader.   However this approach will presumably not work on all systems.

Is there a recommended method of sending a link in an e-mail that will work on all systems (unless of course the user has turned links off, in which case nothing will work).

Thanks in advance for any advice.
Avatar of Peter Hutchison
Peter Hutchison
Flag of United Kingdom of Great Britain and Northern Ireland image

The correct html tag is to use mailto:, not http:
<a href="mailto:email.address.here">Link to email address</a>
@Peter: on reset password links, they are links, not mailtos.

@David: all email clients I know will automatically create links from plain text.
Do you have a sample of the link (not the exact one) but approx syntax?
Avatar of DavidRMason
DavidRMason

ASKER

Peter - the body of the e-mail is created in PHP as follows:

$body='<html><body>'.
                'You have requested a password reset for the xxx web site.  '.
                'Please click the link below to set your password<br><br>'.
                '<a href="http://'.$host.'index.php?action='.$actionCode.'">Reset password</a>'.
                '</body></html>';
where the variable $host contains the web site name beginning www.... and the variable $actionCode contains a randomly generated string that is stored in MYSQL and will time-expire if not clicked promptly, and is linked to the user's e-mail address (which they have to re-enter after clicking the link to validate it).

This works fine except with 2 test members both using Apple devices (iPad and iPhone) who report that nothing happens when the click the link, although other links from other people work for them.

Sending in plain text and having the link created automatically in the user's mail system is a less elegant option as it means the full http://&c is exposed to the user, whereas all they need is a link whose text says "Reset password" that they can click.

As a backup I'm including an option to copy and paste the URL.

Thanks for your help.

David
ASKER CERTIFIED SOLUTION
Avatar of Peter Hutchison
Peter Hutchison
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've seen a lot of "reset" emails say something like:

<a href="http://www.abc.com">Click Here to reset your password</a>. if this link doesn't work, please copy and paste the link below directly into your browsers address bar.

Reset Link - http://www.abc.com

this is a common and accepted practice, as it's always difficult to make ALL browsers happy these days :)
Peter - thanks for your help - putting a proper header in the html solved the problem.

I simply replaced the <html> tag above with

<!DOCTYPE html>
<html>
 <head>
  <meta charset="UTF-8">
 </head>

and it now works.