Nieuw lid |
|
Hallo,
Met behulp van onderstaande code kan ik een mail verzenden. Graag zou ik echter de inhoud van de mail (inclusief de bijlage) kunnen aanpassen met een formulier. Weet iemand hoe dit moet ? Het formulier vindt je hieronder.
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "###"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "###"; // SMTP username
$mail->Password = "###"; // SMTP password
$mail->From = "webmaster@koorpolyhymnia.net";
$mail->FromName = "Polyhymnia";
@MYSQL_CONNECT("localhost","###","###");
@mysql_select_db("###");
$query = "SELECT * FROM `leden_polyhymnia` WHERE `Opgezegd` = 'false' and `Nieuwsbrief`= 'Ja'";
$result = @MYSQL_QUERY($query);
while ($row = mysql_fetch_array ($result))
{
// HTML body
$body = "Inhoud van het bericht<p>";
$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($row["email"], $row["Naam"]);
$mail->AddAttachment("adresstickers.zip", "adresstickers.zip"); // optional name
if(!$mail->Send())
echo "There has been a mail error sending to " . $row["email"] . "<br>";
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
require("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "###"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "###"; // SMTP username $mail->Password = "###"; // SMTP password $mail->From = "webmaster@koorpolyhymnia.net"; $mail->FromName = "Polyhymnia"; $query = "SELECT * FROM `leden_polyhymnia` WHERE `Opgezegd` = 'false' and `Nieuwsbrief`= 'Ja'"; { // HTML body $body = "Inhoud van het bericht<p>"; $mail->Body = $body; $mail->AltBody = $text_body; $mail->AddAddress($row["email"], $row["Naam"]); $mail->AddAttachment("adresstickers.zip", "adresstickers.zip"); // optional name if(!$mail->Send()) echo "There has been a mail error sending to " . $row["email"] . "<br>"; // Clear all addresses and attachments for next loop $mail->ClearAddresses(); $mail->ClearAttachments(); }
Hieronder vindt je het formulier dat ik in de plaats van de bovenstaande velden zou willen hebben.
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"POST\" enctype=\"multipart/form-data\">";
echo "<table>";
echo "<tr>";
echo "<th colspan=\"2\"><div align=\"left\">Mailen naar personen</th>";
echo "</tr>";
echo "<tr>";
echo "<td>Van:</td>";
echo "<td><input type=\"text\" name=\"from\" value=\"Polyhymnia\" size=\"30\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Onderwerp:</td>";
echo "<td><input type='text' name='subject' size=\"30\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Bestand:</td>";
echo "<td><input type='file' name='file' size=\"30\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Bericht</td>";
echo "<td><textarea COLS=\"40\" ROWS=\"5\" name='bericht'></textarea><td>";
echo "</tr>";
echo "<tr>";
echo "<td><input type=\"submit\" value=\"Verzenden\"></td>";
echo "<td></td>";
echo "</form></table>";
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"POST\" enctype=\"multipart/form-data\">"; echo "<th colspan=\"2\"><div align=\"left\">Mailen naar personen</th>"; echo "<td><input type=\"text\" name=\"from\" value=\"Polyhymnia\" size=\"30\"></td>"; echo "<td>Onderwerp:</td>"; echo "<td><input type='text' name='subject' size=\"30\"></td>"; echo "<td>Bestand:</td>"; echo "<td><input type='file' name='file' size=\"30\"></td>"; echo "<td><textarea COLS=\"40\" ROWS=\"5\" name='bericht'></textarea><td>"; echo "<td><input type=\"submit\" value=\"Verzenden\"></td>";
|