views:

24

answers:

4

I have the following code to send an email to the users.

$mes_body.="Click to Login. www.website.com/index.php\n\n";  
$mes_body.= "<a href='www.website.com/index.php'>Click to Login.</a>\n\n";

Right now i am seeing the email as :

Click to Login. www.website.com/index.php

<a href='www.website.com/index.php'>Click to Login.</a>

What is want is a clickable 'Click to Login' and not the link exactly. I guess i am using plaintest. i cant change it right now so is there any workaround for this? Thanks.

A: 

You need to send a HTML E-Mail.

For a simple example on how to do that, see Example #4 in the PHP manual to mail().

You should however always also send along a text alternative for maximum compatibility. To send multipart E-Mails, it's most convenient to use an existing mailing library like SwiftMailer.

Pekka
A: 

See Example #4, "Sending HTML Email", on the PHP mail() documentation page.

The issue is that your message needs MIME headers marking it as HTML rather than plain text.

Borealid
A: 

It is not possible to use HTML formatting without HTML.

(Obviously)

You need to switch to HTML emails or drop the HTML tags.

Note that most email clients will automatically make URLs in plaintext messages clickable.

SLaks
A: 

No. The closest you can come to a hyperlink in plain text email is a URI that the client detects and makes clickable. There is absolutely no way to make the text be anything other than the URI itself.

If you want that, then you need to format your email using HTML (and should make it a multipart email which includes a sensible plain text alternative).

David Dorward