Beste mensen,
Naveel stoeien lukt het me niet.
De bedoeling is dat er een attachment gesturd wordt met een stuk tekst in de mail zelf.
Alleen de Attachment krijg ik netjes mee, alleen de tekst wat erbij moet komen niet.
Ik hoop dat iemand het probleem ziet.
PHP
<div class="subtitle">
<img src="./images/thumbs/icon_newspaper.png" alt="icon" title="icon" class="icon" />
<h3>Solicitatie Formulier</h3>
</div>
<div class="maintxt">
<div id="maintekst">
<div id="tekst" style="display: block;">
<?php
session_start();
$mail_ontv = '****@live.nl';
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
// naam controle
if (!preg_match('/[ a-zA-Z-]$/', $_POST['naam']))
$naam_fout = 1;
// e-mail controle
if (function_exists('filter_var') && !filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL))
$email_fout = 1;
// antiflood controle
if (!empty($_SESSION['antiflood']))
{
$seconde = 60;
$tijd = time() - $_SESSION['antiflood'];
if($tijd < $seconde)
$antiflood = 1;
}
}
if (($_SERVER['REQUEST_METHOD'] == 'POST' && (!empty($antiflood) || empty($_POST['naam']) || !empty($naam_fout) || empty($_POST['mail']) || !empty($email_fout) || empty($_POST['bericht']) || empty($_POST['telefoonnummer']) || empty($_POST['onderwerp']))) || $_SERVER['REQUEST_METHOD'] == 'GET')
{
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (!empty($naam_fout))
echo '<p>Uw naam mag alleen letters bevatten.</p>';
elseif (!empty($email_fout))
echo '<p>Uw e-mailadres is niet juist.</p>';
elseif (!empty($antiflood))
echo '<p>U mag slechts één bericht per ' . $seconde . ' seconde versturen.</p>';
else
echo '<p>U bent uw naam, e-mailadres, onderwerp, Motivatie of CV vergeten in te vullen.</p>';
}
echo '<form method="post" action="' . $_SERVER['REQUEST_URI'] . '" enctype="multipart/form-data" />
<table width="630">
<tr>
<td width="25%"><label for="naam">naam:</label></td>
<td width="75%"><input type="text" id="naam" name="naam" value="' . (isset($_POST['naam']) ? htmlspecialchars($_POST['naam']) : '') . '" /></td>
</tr>
<tr>
<td><label for="mail">E-mailadres:</label>
<td><input type="text" id="mail" name="mail" value="' . (isset($_POST['mail']) ? htmlspecialchars($_POST['mail']) : '') . '" /></td>
</tr>
<tr>
<td><label for="telefoonnummer">Telefoon nummer:</label></td>
<td><input type="text" id="telefoonnummer" name="telefoonnummer" value="' . (isset($_POST['telefoonnummer']) ? htmlspecialchars($_POST['telefoonnummer']) : '') . '" /></td>
</tr>
<tr>
<td><label for="onderwerp">Onderwerp:</label></td>
<td><input type="text" id="onderwerp" name="onderwerp" value="' . (isset($_POST['onderwerp']) ? htmlspecialchars($_POST['onderwerp']) : '') . '" /></td>
</tr>
<tr>
<td><label for="bericht">Motivatie:</label></td>
<td><textarea id="bericht" name="bericht" rows="8" style="width: 400px;">' . (isset($_POST['bericht']) ? htmlspecialchars($_POST['bericht']) : '') . '</textarea></td>
</tr>
<tr>
<td><label for="cv">Curriculum Vitae</label></td>
<td><input type="file" name="fileAttach">
<tr>
<td> </td>
<td><input type="submit" name="submit" value=" Versturen " /></td>
</tr>
</table>
</form>';
}
else
{
$datum = date('d/m/Y H:i:s');
$inhoud_mail = "===================================================\n";
$inhoud_mail .= "Ingevulde contact formulier " . $_SERVER['HTTP_HOST'] . "\n";
$inhoud_mail .= "===================================================\n\n";
$inhoud_mail .= "Naam: " . htmlspecialchars($_POST['naam']) . "\n";
$inhoud_mail .= "E-mail adres: " . htmlspecialchars($_POST['mail']) . "\n";
$inhoud_mail .= "Telefoon nummer: " . htmlspecialchars($_POST['telefoonnummer']) . "\n";
$inhoud_mail .= "Motivatie:\n";
$inhoud_mail .= htmlspecialchars($_POST['bericht']) . "\n\n";
$inhoud_mail .= "Verstuurd op " . $datum . " via het IP adres " . $_SERVER['REMOTE_ADDR'] . "\n\n";
$inhoud_mail .= "===================================================\n\n";
$uid = md5(uniqid(time()));
$headers = 'From: ' . htmlspecialchars($_POST['naam']) . ' <' . $_POST['mail'] . '>';
//*** Attachment ***//
if($_FILES["fileAttach"]["name"] != "")
{
$strFilesName = $_FILES["fileAttach"]["name"];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"])));
$headers .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
$headers .= "Content-Transfer-Encoding: base64\n";
$headers .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
$headers .= $strContent."\n\n";
}
$_POST['onderwerp'] = str_replace('\n', '', $_POST['onderwerp']); // Verwijder \n
$_POST['onderwerp'] = str_replace('\r', '', $_POST['onderwerp']); // Verwijder \r
$_POST['onderwerp'] = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_POST['onderwerp'])); // Slashes van quotes
if (mail($mail_ontv, $_POST['onderwerp'], $inhoud_mail, $headers))
{
$_SESSION['antiflood'] = time();
echo '
<p>Bedankt voor het invullen van het contactformulier. We zullen zo spoedig mogelijk contact met u opnemen.</p>';
}
else
{
echo '
<p><b>Onze excuses.</b> Het contactformulier kon niet verzonden worden.</p>';
}
}
?>
</div>
</div>
Toon Meer