Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I'm trying to send an email to activate new users account. Here is the code:

    //Email
    $to = $Email;
    $subject = "Activation";
    $signature = "Test";
    $server = "smtp.gmail.com";

    ini_set('SMTP', $server);

    $body = "<a href='http://localhost/etc>Click here to activate</a>";

    mail($to, $subject, $signature, $body);

The problem is that the actual mail is showing <a href='http://localhost/etc>Click here to activate</a> when it should only show "Clik here to activate". Any feedback on how to fix that?

share|improve this question
1  
Since this question is about code that does not work the way it is intended to, it does not belong here. Try posting it on StackOverflow. – Joseph Silber Aug 16 '12 at 17:27

closed as off topic by Winston Ewert Aug 16 '12 at 21:26

Questions on Code Review Stack Exchange are expected to relate to code review request within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

2 Answers

up vote 0 down vote accepted

First of all, I would not use single quotes. HTML standard dictates double quotes for attributes, it is just more forgiving than XML. Try this with an XHTML document and you would probably get different results.

Now, as to your problem, since its showing you the entire HTML tag, I would think that means you are getting escaped HTML entities. If you were to view the source you'd probably see &lt;a href=&quot;.... Now, I took a look at the documentation for this, and yep, sure enough "Example #4 Sending HTML email". You'll need to set all those headers they show there.

share|improve this answer
Thanks, that work perfectly =) – Ruble Gomes Aug 16 '12 at 20:30

You are missing a ' after the etc

$body = "<a href='http://localhost/etc'>Click here to activate</a>";
share|improve this answer
Meh that didn't do it. Still showing all the code =/ – Ruble Gomes Aug 16 '12 at 17:00
You were still missing it ;) Is your email set to HTML rather than plain text? – Jeff Vanzella Aug 16 '12 at 17:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.