Mailinglisten-Archive |
Hi Leute,
ich habe Problem beim Versenden von Mails mit HTML-Inhalt via
PEAR::Mail. Mails ohne Content-Type kommen korrekt an.
Begonnen zu haben scheint das Problem, als ich zum Versenden der Mails
auf die Factory-Methode umsteigen musste.
Hier mal der entsprechende Code per Copy & Paste ("..." steht für
entsprechende Daten):
@ini_set('sendmail_from', base64_decode($_SESSION['cl_Mail']));
$Mailserver = '...';
preg_match("|[a-zA-Z0-9].*(@".$Mailserver.")|", $RecMail,
$MailAdresse);
if (empty($MailAdresse)) $RecMail = $RecMail.= '@'.$Mailserver;
$RecName = '...';
$RecMail = '...';
$tmp_Datei = basename($Datei[0]);
$tmp_Link =
'http://'.$_SERVER['HTTP_HOST'].'/fibu/zudd/confirm.php?was=zudd&id='.ba
se64_encode($Datei[1]);
$Boundary = '_'.md5(time());
$InfoText = '<html><body>'."\r\n";
$InfoText.= 'In der Anlage finden Sie die Problemschilderung
bzgl. '."\r\n";
$InfoText.= 'der Zahlungsunregelmässigkeiten Ihres
Kunden.<br><br>'."\r\n\r\n";
$InfoText.= 'Bitte bestätigen Sie den Erhalt dieser Email
mit '."\r\n";
$InfoText.= 'Klick auf den Link <a
href="'.$tmp_Link.'">Bestätigung</a><br><br>'."\r\n\r\n";
$InfoText.= 'Sie können diesen Link auch in Ihren Browser
übernehmen und aufrufen.<br>'."\r\n";
$InfoText.= 'Web-Adresse:
'.htmlentities($tmp_Link).'<br><br>'."\r\n\r\n";
$InfoText.= 'Mit freundlichen
Grüßen<br><br>'.$_SESSION['cl_Benutzer'];
$InfoText.= '</body></html>';
$Content = ' This is a multipart message in MIME format
'."\r\n";
$Content.= "\r\n\r\n--".$Boundary."\r\n";
$Content.= "Content-Type: text/html; charset=iso8859-1\r\n";
$Content.= "Content-Transfer-Encoding: 7Bit\r\n\r\n";
$Content.= $InfoText."\r\n";
$Content.= "\r\n\r\n--".$Boundary."\r\n";
$Content.= "Content-Type: application/octet-stream;
name=\"".$tmp_Datei."\"\r\n";
$Content.= "Content-Transfer-Encoding: base64\r\n";
$Content.= "Content-Disposition: attachment;
filename=\"".$tmp_Datei."\"\r\n\r\n";
$Content.= base64_encode(file_get_contents($Datei[0]))."\r\n";
$Content.= "\r\n\r\n--".$Boundary."--\r\n";
require_once('Mail.php');
$MyMail =& new Mail;
$Factory = $MyMail->factory('smtp', array('host' => '...',
'auth' => true, 'username' => '...', 'password' => '...'));
$Send = $Factory->send('"'.$RecName.'" <'.$RecMail.'>',
array('Reply-To' =>
'...'."\r\n",
'From' =>
'...'."\r\n",
'Cc' =>
'...',
'Subject' =>
'...',
'X-Webit' => '...',
'X-Mailer' => 'PHP
'.phpversion(),
'MIME-Version' =>
'1.0',
'Content-Type' =>
'multipart/mixed; boundary="'.$Boundary.'"'),
$Content);
Ich stehe irgendwie im Regen. Die Anlage, die ganze Mail - alles kommt
klar an. Werde mir mal noch eine Testmail stricken und den ganzen Kram
Schritt für Schritt nochmal durchgehen.
Schon mal Danke für eure Tipps oder Hinweise.
--
MfG, Steffen
php::bar PHP Wiki - Listenarchive