I am figthing against a strange problem. I want to send an utf-8 encoded text/html email. The mail() function returns 1 but the system is not sending the mail.
I found out that this does not happen, when i replace all the "://" in the included links. The mail will be send then.
I have another script on the same server, in the same directory that also includes links and this one works fine.
has anyone an idea what the source of this problem is?
I get the links from a database (utf-8). (just normal links, like "http://www.example.com/blah")
The emails will not be sent by using this code:
while($line = mysql_fetch_array($data)){
$url = $line['url'];
$mailtext.= "<td><a href=\"". $url ."\">". substr($url, 0, 150)."</a></td>";
}
This works:
while($line = mysql_fetch_array($data)){
$url = $line['url'];
$strpos = strpos($url, "://");
$urlpart1 = substr($url, 0, $strpos);
$urlpart2 = substr($url, $strpos+3);
$url = $urlpart1."---".$urlpart2;
$mailtext.= "<td><a href=\"". $url ."\">". substr($url, 0, 150)."</a></td>";
}
This is how i send the mail:
function mailInform($subject, $text){
$mail = "mymail@example.com";
if(get_magic_quotes_gpc())
{
$text = stripslashes($text);
}
$header = "From: something <something@myurl.org>
";
$header .= "Content-type: text/html; charset=UTF-8
";
$header .= "Content-Transfer-encoding: 8bit
";
$header .= "MIME-Version: 1.0
";
$subject = "=?UTF-8?B?".base64_encode($subject)."?=";
return mail($mail, $subject, $text, $header);
}
if you send it as UTF-8 change header as from:
$header .= "Content-type: text/html; charset=UTF-8
";
$header .= "Content-Transfer-encoding: 8bit
";
to:
$header .= " Content-type: text/plain; charset=UTF-8
";
and also add the html meta tag in html:
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />