RE: php Mail versenden
Alles sicherlich richtig was hier steht, aber von der Architektur grauenhaft.
Vielleicht reicht es schon, wenn du folgende Zeile weglässt,
dass ist definitiv ein encoding Fehler:
$text=utf8_encode($text);
oder mache daraus ein
$text=utf8_decode($text);
Welches Encoding hat dein PHP Dokument? Mach dass auf UTF-8
Sende auch folgenden Header:
header('content-type: text/html; charset=utf-8');
Sollte eigentlich all das nicht beinflussen, aber setzte auch den meta Bereich von Html auf UTF-8
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
[/php]
Edit: Hier mal eine Mail Klasse von mir, die funktionert solange der header auf utf8 gesetzt ist
<?php class email { var $email; var $betreff; var $an; var $von; function email ($tpl) { $this -> email = $tpl; if (file_exists ($this -> email)) { $fp = fopen ($this -> email, "r"); $text = fread ($fp, filesize($this -> email)); fclose ($fp); $this -> email = $text; } else { $this -> email = $tpl; } } function an ($an) { $this -> an = $an; } function betreff ($betreff) { $this -> betreff = $betreff; } function von ($adresse, $name = '') { if (!empty ($name)) { $this -> von = 'From: '. $name . '<' . $adresse . '>'; } else { $this -> von = 'From: '. $adresse; } } function headers ($an, $betreff, $von_adresse, $von_name = '') { $this -> an ($an); $this -> betreff ($betreff); $this -> von ($von_adresse, $von_name); } function parse ($search, $replace) { $this -> email = str_replace ($search, $replace, $this -> email); } function send () { $this -> email = utf8_decode ($this -> email); $this -> betreff = utf8_decode ($this -> betreff); $this -> an = utf8_decode ($this -> an); $this -> von = utf8_decode ($this -> von); if (mail ($this -> an, $this -> betreff, $this -> email, $this -> von)) { return true; } else { return false; } } } ?>
So rufst du die auf:
$noti_mail = new email ('pfad_zum_tempalte_welches_auch_utf_8_ist.txt'); $noti_mail -> headers ("empfänger", "betreff", "absender", "absenderName"); $noti_mail -> parse ('%var%', $var); $noti_mail -> parse ('%var%', $var); $noti_mail -> parse ('%var%', $var); $noti_mail -> parse ('%var%', $var); $noti_mail -> send();
Freundliche Grüße,
[Link: Registrierung erforderlich]
Full Stack Software Engineer & Architekt
Sprachen: C#, TSQL, HTML5, Ecmascript 6, CSS 3.1, (TS, C++, PHP)
Frameworks: .NET, .NET Core, ASP.NET MVC, ASP.NET WebApi, WPF, WCF, Entity Framework, Bootstrap
Dieser Beitrag wurde zuletzt bearbeitet: 13.01.2013 16:30 von GGSeSports.
|