The code works to send the email with link included bu the URL does not open. Can anyone help?

//Send Email For Account Confirmation

$message="Please activate your account by running this link:"."\n\n"; 

$headers = 'From:'.$s_mail."\n" .
    'Reply-To:'.$s_mail."\n" .
    'X-Mailer: PHP/' . phpversion();

mail ($emailaddress,'New Account Confirmation',$message,$headers);


link goes here:

If you paste the url into your address bar in your browser and go directly to it, does it work?

If it works and you truly are just trying to make it a clickable link in the email, then

$message .= "<a href='$s_web/confirmaccount.php?code=$encryptpass&id=$id'>confirm account</a>";

Thanks but that did not work in the message. BTW the email link does confirm the registration when you go to that link. I would put a thank you message at that url but it really doesnot exist. Any ideas?

Maybe you don't have html text enabled in your email client, in which case you're screwed.

Need to set all the appropriate headers for sending html email.

Without getting to overly complicated (because you could make this a lot more complex), this is how I would probably do this

$s_web = "http://".$_SERVER[HTTP_HOST];

$subject = "New Account Confirmation";

$message = "<html><body>";
$message .= "<h1>Account Confirmation</h1>";
$message .= "<p>Please activate your account by running this link:</p><br />";
$message .= "<a href='$s_web/confirmaccount.php?code=$encryptpass&id=$id'>confirm account</a>";
$message .= "</body></html>";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'To: <' . $emailaddress.'>' . "\r\n";
$headers .= 'From:' . $s_mail . "\r\n";
$headers .= 'Reply-To:' . $s_mail . "\r\n";
$headers .= 'Subject:' . $subject . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();

mail($emailaddress, $subject, $message, $headers);

I usually dump my headers into an array, etc. But this way works too. I also like using an html template rather than dumping the html into my PHP.

red pill, the headers solved the link in the email but that is not this issue. thanks for that. where I have an issue is the link opens to a 404 error. I need it to redirect to the location, after confirmation.

PS I think I need to add this somewhere: header("location:index.php");

the question is where do I put it?

It's hard to say without seeing the rest of your code. However, why are you getting a 404 error for confirmaccount.php? If done correctly, I would think you should not be getting a 404 error.

red, that is the issue here is the link generated via email: would you check to see if it is not my machine?

I get a custom 404 error message as well. Double check the name and location of that file. It's also possible that the nginx config settings could play a part in this, just like htaccess on Apache.