PHP-Code:
<?php
error_reporting(E_ALL | E_STRICT);
// ... Datenbankabfrage
// Initialisierungen
$plain = "hallo newsletter";
$email = '';
// enthält Inhalt des Newsletters
$html = '';
while ($myrow = mysql_fetch_array($result)) {
if ($email != $myrow['email']) {
echo '<p>[DEBUG] e-mail wechselt</p>';
if ($email != '') {
$mail->AddAddress = $email;
$mail->Subject = "Our Newsletter";
$mail->Body = $html;
$mail->AltBody = $plain;
$mail->Send();
$mail->ClearAddresses();
echo '<p>[DEBUG] e-mail gesendet</p>';
}
// neuen Vergleichswert setzen
$email = $myrow['email'];
// Inhalt des Newsletters leeren
$html = '';
}
// neuen Datensatz zum Newsletterinhalt hinzufügen
$html .= '<p>' . $myrow["stelleID"] . '</p>';
$html .= '<p>' . $myrow["stellePosition"] . '</p>';
$html .= '<p>' . $myrow["stelleAngebot"] . '</p>';
$html .= '<p>' . $myrow["email"] . '</p>';
}
Gruß
Kommentar