I have a really weird error with the mail() function in php.
This is the code i'm using to send the message:
$to = strip_tags($_POST['newMail']);
$subject = "Company: Update your email address ";
$message = $mailHeader.'<b>Hello from Company!</b><br/> <br/> Please confirm your new email address by clicking this link: <a href="http://www.Company.com/confirm.php?regID='.$regID.'&newemail='.mysql_escape_string($_POST['newMail']).'" class="link"> Confirm Email Address Change</a><br/><br/><p class="p"><b>Thank you.</b></p><br/><b class="h2">Company.</b>'.$mailFooter;
$from = "<noreply@company.com>";
$headers = "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";
$headers .= "From: Company Name" . $from. "
";
To note, the company name has been replaced with 'company'.
EDIT - $mailHeader
<html>
<style>
/* `XHTML, HTML4, HTML5 Reset
----------------------------------------------------------------------------------------------------*/
body {
border: 0;
margin: 0;
padding: 0;
font-size: 100%;
}
html,
body {
height: 100%;
}
.link{
color:#81c6f6;
text-decoration:none;
}
.link:visited {
color:#81c6f6;
}
.link:hover {
color:#f6b181;
}
.h1{
color:#696969;
font:20px/1.5 Helvetica, Geneva, sans-serif;
}
.p{
padding:2px;
color:#787878;
font:16px/1.5 Tahoma, Geneva, sans-serif;
}
.h2{
padding:2px;
color:#81c6f6;;
font:16px/1.5 Tahoma, Geneva, sans-serif;
}
.roundAll{
-moz-border-radius:20px;
border-radius:20px;
-webkit-radius: 20px;
}
#header{
height:71px;
width:100%;
background-color:#99d1f8;
}
#automarginwrap{
width:90%;
margin:0 auto;
text-align:center;
}
#content{
margin:0 auto;
padding:10px;
width:80%;
border: solid 10px #f1f1f1;
background-color:#fff;
}
</style>
<body>
<div id="header"><center><img src="http://www.downloadablecreations.com/images/logo.png" /></center></div>
<div id="automarginwrap">
<div id="content" class="roundAll h1">
$mailFooter -
</div>
</div>
</body>
</html>
Now this works fine, the mail is sent and received no error message appear, however when i click on the link, it directs me to a url missing either a 'w' in the href part of the message (Mail.app Apple):
<a href="http://ww.Company.com/confirm.php?
Or a random letter from the link:
<a href="http://www.Compay.com/confirm.php?
Am i doing something wrong?
I believe the error lies in the charset aspect of the email or the encoding.
EDIT - removing mysql_escape_string() made no difference to the result.