I am having some serious problem with some e-mail issue.
in short:
- loading a html template file
fopen
- replacing some values, marked like this
%password
with real valuesstr_replace
- sending mail via the following function, where
$content
is the loaded html template file:
public function send($receiver, $subject, $content){
$header = "From:".sender. "
";
$header .= "MIME-Version:1.0" . "
";
$header .= "Content-type:text/html;charset=utf-8" . "
";
$mailText = $content;
mail($receiver, $subject, stripslashes(iconv('utf-8', 'iso-8859-1', $mailText)) , $header);
}
the server is debian with postfix.
The Mail template starts with
<html> <body style="background-color: #fff;"> <table border="0"...
The thing is, and I cannot reproduce it, that in some cases I can find several spaces in the mail, which I didn't put there. Most problematical are those in the user and password string.
Evering else seems correct! The encoding is ok, the html is accepted, all mails can be delivered ...
password generation:
public static function create_password($length = 12) {
$characters = array("a", "b", "c", "d", "e", "f", "g", "h", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "_");
$password = "";
for($i=0; $i<$length; $i++) {
$index = rand(1, count($characters)) -1;
$password .= $characters[$index];
}
$password = str_replace("__","_", $password);
return $password;
}
Any Ideas, where to start my search?
Is it the template, str_replace, the postifix, the client, ... ?
Thanks so far