Hej jeg har fundet en PHP Mail sender men får den her fejl:
"Warning: Cannot modify header information - headers already sent by (output started at minside/pages/kontakt/kontakt.php:2) in minside/pages/kontakt/kontakt.php on line 62"
når jeg prøver at sende en mail.. her er mit script:
kontakt.php
<center
<?
$emailto = 'MINEMAIL';
$fejl = array();
if ($_SERVER["REQUEST_METHOD"]=='POST') {
$ip = $_SERVER['REMOTE_ADDR'];
$user_agent = $_SERVER["HTTP_USER_AGENT"];
$name = @$_POST['name'];
$email = @$_POST['email'];
$subject = @$_POST['subject'];
$headers = "MIME-Version: 1.0\\r\\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\\r\\n";
$headers .= "From: $name <$email>";
$text = @$_POST['text'];
$message = "
<html>
<head>
</head>
<body>
<table>
<tr>
<td>Navn:</td><td>$name</td>
</tr>
<tr>
<td>Mail:</td><td>$email</td>
</tr>
<tr>
<td>Emne:</td><td>$subject</td>
</tr>
<tr>
<td>Text:</td><td>$text</td>
</tr>
<tr>
<td>User IP:</td><td>$ip</td>
</tr>
<tr>
<td>User Agent:</td><td>$user_agent</td>
</tr>
</table>
</body>
</html>";
if (!$name)
$fejl[] = "Du glemte at udfylde dit navn.";
if (!$email)
$fejl[] = "Du glemte at udfylde din mail adresse";
if (!$subject)
$fejl[] = "Du glemte at udfylde emne.";
if (!$text)
$fejl[] = "Du glemte at skrive en besked.";
if (count($fejl)==0) {
$sendt = "Ja";
mail($emailto, $subject, $message, $headers);
header('Location: sendt.php');
exit;
}
}
if ($sendt == "Ja") {
} else {
}
if (count($fejl)>0) {
// Der er fejl
echo '<p class="error">';
echo join('<br />', $fejl);
echo '</p>';
}
?>
<link href="../../css/styleindhold.css" rel="stylesheet" type="text/css" />
<form action="kontakt.php" method="post" name="Sendmail" id="Sendmail">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="5" colspan="2"></td>
</tr>
<tr>
<td><font size="2">Navn:</font><br />
<input type="text" style="height:20px;color: #666666; border: 1px solid #C0C0C0; background-color:#FFFFFF" class="text" name="name" id="name" size="30"></td>
</tr>
<tr>
<td><font size="2">Email:</font><br />
<input type="text" style="height:20px;color: #666666; border: 1px solid #C0C0C0; background-color:#FFFFFF" class="text" name="email" id="email" size="30"></td>
</tr>
<tr>
<td><font size="2">Emne:</font><br />
<input type="text" style="height:20px;color: #666666; border: 1px solid #C0C0C0; background-color:#FFFFFF" class="text" name="subject" id="subject" size="30"></td>
</tr>
<tr>
<td height="132"><font size="2">Besked:</font><br />
<textarea name="text" style="height:100px; width:280px; color: #666666; border: 1px solid #C0C0C0; background-color:#FFFFFF" class="textarea" id="text"></textarea><br />
<input style=" margin-top:2px; color: #666666; font-size: 8pt; border: 1px solid #C0C0C0; padding: 2px; background-color:#FFFFFF" type="submit" class="submit" name="Submit" value="Send mail" />
<input style=" margin-top:2px; color: #666666; font-size: 8pt; border: 1px solid #C0C0C0; padding: 2px; background-color:#FFFFFF" type="reset" class="submit" name="Reset" value="Slet alt" /></td>
</tr>
<tr>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</form>
</p>
</center>
Sendt.php
<link href="css.css" rel="stylesheet" type="text/css" />
<font color="#339933">Mailen er nu sendt</font>