Prova questo:
1. Form per la compilazione dell'email:
Codice PHP:
<html>
<head>
<title>Enter E-mail</title>
</head>
<body>
<form name="theform" method="post" action="sendmail.php">
<table>
<tr>
<td>To:</td>
<td><input type="text" name="to" size="50"></td>
</tr>
<tr>
<td>From:</td>
<td><input type="text" name="from" size="50"></td>
</tr>
<tr>
<td>Cc:</td>
<td><input type="text" name="cc" size="50"></td>
</tr>
<tr>
<td>Bcc:</td>
<td><input type="text" name="bcc" size="50"></td>
</tr>
<tr>
<td>Subject:</td>
<td><input type="text" name="subject" size="50"></td>
</tr>
<tr>
<td valign="top">Message:</td>
<td>
<textarea cols="60" rows="10" name="message"></textarea>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Invia">
<input type="reset" value="Cancella tutto">
</td>
</tr>
</table>
</form>
</body>
</html>
2. Invio dell'email: pagina che devi chiamare sendmail.php
Codice PHP:
<html>
<head>
<title>Mail Inviata!</title>
</head>
<body>
<?php
$to = $_POST["to"];
$cc = $_POST["cc"];
$bcc = $_POST["bcc"];
$from = $_POST["from"];
$subject = $_POST["subject"];
$messagebody = $_POST["message"];
$boundary = "==MP_Bound_xyccr948x==";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"$boundary\"\r\n";
$headers .= "CC: " . $cc . "\r\n";
$headers .= "BCC: " . $bcc . "\r\n";
$headers .= "From: " . $from . "\r\n";
$message = "This is a Multipart Message in MIME format\n";
$message .= "--$boundary\n";
$message .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n";
$message .= $messagebody . "\n";
$message .= "--$boundary\n";
$message .= "Content-Type: text/plan; charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= $messagebody . "\n";
$message .= "--$boundary--";
$mailsent = mail($to, $subject, $message, $headers);
if ($mailsent) {
echo "Il messaggio è stato inviato:
";
echo "[b]To:[/b] $to
";
echo "[b]From:[/b] $from
";
echo "[b]Subject:[/b] $subject
";
echo "[b]Message:[/b]
";
echo $message;
} else {
echo "Errore! Messaggio non inviato";
}
?>
</body>
</html>