<?php
…
// Einstellungsänderungen zur Erhöhung der Fehlersensibilität
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
define('CRLF', chr(0x0D).chr(0x0A));
if( isset($_POST['sendmail']) && !empty($_POST['mailto']) && !empty($_POST['subject']) && !empty($_POST['message']) && isset($_POST['bildid'])) {
$query = "
SELECT
*
FROM
`bilder`
WHERE
`id` = '".intval($_POST['bildid'])."'
";
$result = mysql_query($query);
$row = mysql_fetch_assoc($bilder, MYSQL_ASSOC);
$boundary = md5(uniqid());
$header_fields = array(
'MIME-Version: 1.0',
'Content-Type: multipart/mixed; boundary='.$boundary,
'From: user@example.net'
);
$header = join(CRLF, $header_fields);
$header .= CRLF.CRLF.'--'.$boundary;
$header_fields = array(
'Content-Type: text/plain; charset=iso-8859-1',
'Content-Transfer-Encoding: quotet-printable'
);
$header .= CRLF.CRLF.join(CRLF, $header_fields);
$header .= CRLF.CRLF.imap_8bit($_POST['message']);
$header .= CRLF.CRLF.'--'.$boundary;
$image_mimetype = ( getimagesize($row['dateiname']) !== false )
? end(getimagesize($row['dateiname']))
: 'application/octet-stream';
$header_fields = array(
'Content-Type: '.$image_mimetype,
'Content-Transfer-Encoding: base64',
'Content-Disposition: attachment; filename="'.basename($row['dateiname']).'"'
);
$header .= CRLF.CRLF.join(CRLF, $header_fields);
$header .= CRLF.CRLF.chunk_split(base64_encode(file_get_contents($row['dateiname'])));
$header .= CRLF.CRLF.'--'.$boundary;
$header .= '--';
imap_mail($_POST['mailto'], $_POST['subject'], '', $header);
}
?>