Email php link


#1

I have an email constructed which is used to verifiy a new user. Upon registering, an email is sent out with a verification link in it.
The following is the body of the email that is sent out

$mail_body=<<<MAIL

Hi $validusername,

Please click on the following link to verify your new account:

$verifyurl?email=$verifyemail&verify=$verifystring

MAIL;

The email is fine and sends, but the $verify?.. variable line for the verification link to my veirify.php page which the user is supposed to click on just shows as it is above. You can’t click on it etc etc.

Something I’m doing wrong but what?

Cheers
M


#2

Personally I find the HEREDOC method to be cumbersome and don’t use it. Additionally there is an important note about it at http://us3.php.net/manual/nl/language.t … ax.heredoc Perhaps the last line is causing the problem?

I would do it as follows:

[php]
$mail_body="
Hi $validusername,

Please click on the following link to verify your new account:

$verifyurl?email=$verifyemail&verify=$verifystring ";
[/php]
Which should work just as well. You might have to add rn or
as appropriate but I think it’s better than HEREDOCs. (Again, that’s my personal opinion)


#3

You will also want to keep your variables outside the quotes, just to make sure they’re parsed (as not all quotes parse encapsulated (for a lack of a better word) variables):

[php]
$mail_body = “Hi “.$validusername.”,rn”;
$mail_body .= “Please click on the following link to verify your new account:rn”;
$mail_body .= $verifyurl."?email=".$verifyemail."&verify=".$verifystring;
[/php]

Edit: note that I used Windows-style line breaks (carriage return, line feed). On Unix this is different.