code:
PHP:
<?php
if ($_REQUEST['Invia']) {
//echo $file;
//aggiungo gli allegati
copy("$file","$file_name");
include ("class.phpmailer.php");
//creazione istanza phpmailer
$mail = new phpmailer();
//seleziona il protocollo SMTP come modalità di spedizione
$mail->IsSMTP();
//nome dominio
$mail->Host = "smtp.nuovacarrozzeriastella.it";
//segnala che è richiesta l autenticazione
$mail->SMTPAuth = TRUE;
//indicazione nome utente e password
$mail->Username = 'preventivi@nuovacarrozzeriastella.it';
$mail->Password = '***';
//mittente
$mail->From = $_REQUEST['From'];
$mail->FromName = $_REQUEST['FromName'];
//$mail->From = "preventivi@nuovacarrozzeriastella.it";
//$mail->FromName = "preventivi stella";
//destinatario
//$mail->AddAddress($_REQUEST['TO'], $_REQUEST['ToName']);
$mail->AddAddress('preventivi@nuovacarrozzeriastella.it');
//aggiungo gli allegati
//@copy("$file","foto/$file_name");
//$mail->AddAttachment('68.png');
$mail->AddAttachment($file);
//echo $file1."<br>";
//$mail->AddAttachment($file2);
//echo $file2."<br>";
//$mail->AddAttachment($file3);
//echo $file3."<br>";
//oggetto e testo del messaggio
$mail->Subject = $_REQUEST['Subject'];
$mail->Body = $_REQUEST['Message'];
//formato testo o html
$mail->IsHTML = (boolean) $_REQUEST['FormatoHTML'];
if($mail->IsHTML) $mail->AltBody = strip_tags($_REQUEST['Message']);
if($mail->Send()) {
echo "<h2><p>Messaggio inviato con successo!</p></h2>";
} else {
echo "<p>Errore: ".$mail->ErrorInfo."</p>";
}
}
?>
<form method="post" enctype="multipart/form-data">
<table>
<tr>
<td>Nome del mittente: </td>
<td><input type="text" name="FromName" size="40" value="<?= htmlspecialchars($_REQUEST['FromName']) ?>"></td>
</tr>
<tr>
<td>Email del mittente: </td>
<td><input type="text" name="From" size="40" value="<?= htmlspecialchars($_REQUEST['From']) ?>"></td>
</tr>
<!--<tr>
<td>Nome del destinatario: </td>
<td><input type="text" name="ToName" size="40" value="<?= htmlspecialchars($_REQUEST['ToName']) ?>"></td>
</tr>
<tr>
<td>Email del destinatario: </td>
<td><input type="text" name="To" size="40" value="<?= htmlspecialchars($_REQUEST['To']) ?>"></td>
</tr>
-->
<tr>
<td>Oggetto: </td>
<td><input type="text" name="Subject" size="40" value="<?= htmlspecialchars($_REQUEST['Subject']) ?>"></td>
</tr>
<tr>
<td>Messaggio: </td>
<td><textarea name="Message" rows="7" cols="40"><?= htmlspecialchars($_REQUEST['Message']) ?></textarea></td>
</tr>
<!--<tr>
<td></td>
<td><input type="checkbox" name="FormatoHTML" <?= $_REQUEST['FromatoHTML'] ? 'checked="yes"' : '' ?>> Invia in formato HTML</td>
</tr>
-->
<tr>
<td>Pima foto: </td>
<td><input type="file" name="file" size="40"></td>
</tr>
<!--<tr>
<td>Seconda foto: </td>
<td><input type="file" name="file2" size="40"></td>
</tr>
<tr>
<td>Terza foto: </td>
<td><input type="file" name="file2" size="40"></td>
</tr>
-->
<tr>
<td></td>
<td><input type="submit" name="Invia" value="Invia messaggio"></td>
</tr>
</table>
</form>