Hallo,
Ik heb een script geschreven dat een html form verwerkt tot pdf-document en die vervolgens mailt naar een adres. De mail komt vervolgens aan met het pdf-doucment als attachement.
Probleem:
Als ik mijn mail online check werkt alles voorbeeldig, maar als de mail aankomt in Outlook is mail en attachement allemaal in plain text. Hoe kan ik dit oplossen.
Vereenvoudigd voorbeeld van mijn script:
<?
if(isset($_POST['Submit']))
{
$html='<center><h2><font color="#FF0000">A A N M E L D I N G S F O R M U L I E R</font></h2><p></center>';
$html.='<table border="0">';
$html.='<tr><td>Ik meld mij aan voor:</td><td valign="top">'.$aanmld.'</td></tr>';
$html.='<tr><td>Naam:</td><td>'.$naam.'</td></tr></table>';
require('html2fpdf.php');
$pdf=new HTML2FPDF();
$pdf->AddPage();
$pdf->WriteHTML($html);
$pdfcontent = $pdf->Output("aanmelding.pdf", "S");
require_once('Mail.php');
require_once('Mail/mime.php');
// email address of the recipient
// $to = "[email protected]";
$to = "[email protected]";
// email address of the sender
$from = $email;
// subject of the email
$subject = "Aanmelding van ".$naam;
// email header format complies the PEAR's Mail class
// this header includes sender's email and subject
$headers = array('From' => $from,
'Subject' => $subject);
// We will send this email as HTML format
$htmlbody = '<html><body bgcolor="#ffffff"><center>';
$htmlbody.='<table><tr><td colspan="2"><b>INSIGHTOROUT AANMELDING</b></td></tr>';
$htmlbody.='<tr><td>Van:</td><td>'.$naam.'</td></tr></table>';
$htmlbody.='Zie attachement voor verdere aanmelding<p>';
$htmlbody.='</body></html>';
// create a new instance of the Mail_Mime class
$mime = new Mail_Mime();
// set HTML content
$mime->setHtmlBody($htmlbody);
// IMPORTANT: add pdf content as attachment
$mime->addAttachment($pdfcontent, 'application/pdf', 'aanmelding.pdf', false, 'base64');
// build email message and save it in $body
$body = $mime->get();
// build header
$hdrs = $mime->headers($headers);
// create Mail instance that will be used to send email later
$mail = &Mail::factory('mail');
// Sending the email, according to the address in $to,
// the email headers in $hdrs,
// and the message body in $body.
$mail->send($to, $hdrs, $body);
echo '<html><body><center><h2><font color="#FF0000">Bedankt voor de aanmelding!</font></h2></center></body></html><p>';
}
?>
1.096 views
knop om je tekst aan te passen.