功能mail()[关闭]

Look this code:

$to="$email";
$sub="Hi";
$mex="hi <br />  \"<a href='http://exemple.com/ver.php?id=$cod'</a>"\";
$int  = "From:h@h.com";
$int .= "Reply-To:try@try.com";
$int .= "X-Mailer: PHP/".phpversion();
mail($to, $sub, $mex, $int);

The error is on $mex, I think it's on "<a href.."

How to fix this?

$to="$email";
$sub="Hi";
$mex="hi <br /> <a href='http://exemple.com/ver.php?id=$cod'>something</a>";
$int  = "From:h@h.com";
$int .= "Reply-To:try@try.com";
$int .= "X-Mailer: PHP/".phpversion();
mail($to, $sub, $mex, $int);

Try so

$mex="hi <br />  \"<a href='http://exemple.com/ver.php?id=$cod'</a>\"";
$mex="hi <br />  \"<a href='http://exemple.com/ver.php?id=$cod'></a>\"";

You misplaced the last backslash (\), it should be used to escape the ";

Note: Using a library like Swiftmailer instead of mail() would make your life much easier. For example with adding headers (you should add CRLF after every header, as stated on the manual page). Honestly, I don't think beginners should use the mail() function at all. Been there, done that.

$mex="hi <br />  \"<a href='http://exemple.com/ver.php?id=$cod'</a>"\";

should be

$mex= "hi <br/><a href='http://exemple.com/ver.php?id=$cod'>something here</a>";

No need to surround the <a href ... ></a> in quotes and you probably want to put something in the middle of the > and </a> to allow the user to click

$mex="hi <br />  <a href=\"http://exemple.com/ver.php?id=$cod\">Your link text HERE</a>";

Also the headers should be ended by newlines:

$int  = "From:h@h.com
";
$int .= "Reply-To:try@try.com
";
$int .= "X-Mailer: PHP/".phpversion()."
";

The newline is OS dependant and this works on Windows, for UNIX use only or .