Gumbo
Erfahrenes Mitglied
Mein Vorschlag:
PHP:
<?php
if( $_SERVER['REQUEST_METHOD'] != 'POST' || !isset($_POST['guid']) || $_POST['guid'] != php_logo_guid() ) {
header('HTTP/1.1 400 Bad Request', true, 400);
exit;
}
$_recordCount = 10;
$_POST['offset'] = ( isset($_POST['offset']) && intval($_POST['offset']) >= $_recordCount )
? intval($_POST['offset'])
: 0;
$_headerFields = array(
'MIME-Version' => '1.0',
'Content-Type' => 'text/plain; charset=iso-8859-1',
'From' => 'test-versand <test@stuvwxyz.de>'
);
$_additionalHeader = '';
foreach( $_headerFields as $key => $value ) {
$_additionalHeader .= $key . ': ' . $value . chr(0x0D).chr(0x0A);
}
$query = '
SELECT
…
FROM
…
ORDER BY
`id`
LIMIT
'.$_POST['offset'].', '.$_recordCount.'
';
$result = mysql_query($query)
or die(mysql_error());
while( $row = mysql_fetch_assoc($result) ) {
if( mail($to, $subject, $body, $_additionalHeader) ) {
$_POST['offset']++;
} else {
break;
}
}
$fp = fsockopen($_SERVER['HTTP_HOST'], $_SERVER['SERVER_PORT'], $errno, $errstr, 3);
if( $fp ) {
fputs($fp, "POST ".$_SERVER['PHP_SELF']." HTTP/1.0\r\n\r\n");
fputs($fp, 'guid='.php_logo_guid().'&offset='.$_POST['offset']);
fclose($fp);
}
exit;
?>