Beste,
Ik heb een script gemaakt waarbij mensen kunnen soliciteren, en daarbij hun CV opsturen
Alleen op de orignele server waar hetmoet draaien stuurt hij wel de mail, maar het bestand niet.
En op me andere server krijg ik de melding:
Onze excuses. Het contactformulier kon niet verzonden worden.
Ik zie door het bos de bomen niet meer.
het gaat om het volgende script:
PHP
<h2 class="content">Solicitatie Formulier</h2>
<?php
session_start();
$mail_ontv = '**********';
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
{
ob_start();
$datum = date('d/m/Y H:i:s');
$inhoud_mail = "===================================================\n";
$inhoud_mail .= "Ingevulde solicitatie 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";
/* Attachment File */
$file_name = $_FILES["fileAttach"]["name"];
// Read the file content
$file = $file_name;
$file_size = filesize($file);
$handle = fopen($file, "r");
fclose($handle);
$content = chunk_split(base64_encode($_FILES["fileAttach"]["tmp_name"]));
/* Set the email header */
// Generate a boundary
$boundary = md5(uniqid(time()));
// Email header
$headers = "MIME-Version: 1.0\r\n";
$headers .= 'From: ' . htmlspecialchars($_POST['naam']) . ' <' . $_POST['mail'] . '>';
// Multipart wraps the Email Content and Attachment
$headers .= "Content-Type: multipart/mixed; boundary=\"".$boundary."\"\r\n";
// Email content
// Content-type can be text/plain or text/html
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$headers .= $inhoud_mail."\r\n";
// Attachment
// Edit content type for different file extensions
$headers .= "Content-Type: application/octet-stream; name=\"".$file_name."\"\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
$headers .= "Content-Disposition: attachment; filename=\"".$file_name."\"\r\n\r\n";
$headers .= $content."\r\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'], "", $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>';
}
}
?>
Toon Meer