# http://localhost/test_site/php/test/MAIL/PHPMail_Test.php
if (isset($_POST['Submitted'])){
// estrae e stampa variabili e valori da $_POST
print '<table width="500" border="0" cellspacing="5" cellpadding="5">';
while(list($chiave, $valore)=each($_POST)){
${$chiave}=trim(strip_tags($valore));
print "<tr><td>".$chiave." : </td><td>".${$chiave}."</td></tr>";
}
print "</table>";
// require_once 'Config_MAIL.php'; // servizi SMTP disponibili
// SMTPservice(1); // sceglie il servizio SMTP da usare per invio mail, da Config_MAIL.php
// utilizza i parametri seguenti NON quelli di php.ini, solo per questo script
ini_set("SMTP" ,$eM_Host);
ini_set("smtp_port",$eM_Port);
ini_set("username" ,$eM_username);
ini_set("password" ,$eM_password);
// prepara e invia messaggio
// per FROM viene usato $eM_username per evitare il rifiuto dell' invio (invece che $emailFROM)
$eM_header = "MIME-Version: 1.0\r\n";
$eM_header.= "Content-type: text/html; charset=utf-8\r\n";
$eM_header.= "From: <".$eM_username.">\r\n";
if(!empty($eM_CC1)) $eM_header.= "cc: " .$eM_CC1 ."\r\n"; // copia conoscenza
if(!empty($eM_BCC1)) $eM_header.= "Bcc: ".$eM_BCC1."\r\n"; // copia conoscenza nascosta
if(!empty($eM_ReplyTo)) $eM_header.= "Reply-To: ".$eM_ReplyTo."\r\n"; // rispondere a ...
if (mail($eM_TO1, $eM_subject, $eM_body, $eM_header)) print "<b>MESSAGGIO INVIATO</b>";
else print "<b>ERRORE : MESSAGGIO NON INVIATO</b>";
print "<br /><br /><a href=\"PHPMail_Test.php\">RIPROVA</a>";
}
else{
require_once 'Config_MAIL.php'; // servizi SMTP disponibili
SMTPservice(1); // sceglie il servizio SMTP da provare per invio mail, da Config_MAIL.php
?>
<!DOCTYPE html>
<form action="PHPMail_Test.php" method="post" enctype="multipart/form-data" name="myform" id="myform">
<table width="500" border="0" cellspacing="5" cellpadding="5">
<caption> </caption>
<tr>
<td colspan="2"><b>PROVA INVIO MAIL (funzione mail di php)</b></td>
</tr>
<tr>
<td width="165"><label for="eM_Host">Servizio SMTP :</label></td>
<td width="300"><input type="text" name="eM_Host" id="eM_Host" required value="<?= $eM_Host; ?>" size="50"></td>
</tr>
<tr>
<td width="165"><label for="eM_Port">Porta :</label></td>
<td width="300"><input type="text" name="eM_Port" id="eM_Port" required value="<?= $eM_Port; ?>" size="50"></td>
</tr>
<tr>
<td><label for="eM_username">Utente registrato :</label></td>
<td><input type="email" name="eM_username" id="eM_username" required value="<?= $eM_username; ?>" size="50"></td>
</tr>
<tr>
<td><label for="eM_password">Password :</label></td>
<td><input type="text" name="eM_password" id="eM_password" required value="<?= $eM_password; ?>" size="50"></td>
</tr>
<tr>
<td><label for="eM_FROM">e-mail from :</label></td>
<td><input type="email" name="eM_FROM" id="eM_FROM" required value="<?= $eM_username; ?>" size="50"></td>
</tr>
<tr>
<td><label for="eM_TO1">e-mail to :</label></td>
<td><input type="email" name="eM_TO1" id="eM_TO1" required value="<?= $eM_TO1; ?>" size="50"></td>
</tr>
<tr>
<td><label for="eM_subject">Oggetto :</label></td>
<td><input type="text" name="eM_subject" id="eM_subject" required value="oggetto per messaggio di prova" size="50"></td>
</tr>
<tr>
<td><label for="eM_body">Messaggio :</label></td>
<td><input type="text" name="eM_body" id="eM_body" required value="testo del messaggio di prova" size="50"></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><input name="submit" type="submit" id="submit" formaction="PHPMail_Test.php" formenctype="multipart/form-data" formmethod="POST" value="Invia"></td>
</tr>
<tr>
<td colspan="2"><span class="autorizzo">Autorizzo ai sensi del D. Lgs. 30 Giugno 2003 n. 196 il trattamento dei dati personali trasmessi</span></td>
</tr>
</table>
<input type="hidden" name="eM_TO2" value="">
<input type="hidden" name="eM_CC1" value="">
<input type="hidden" name="eM_BCC1" value="">
<input type="hidden" name="eM_ReplyTo" value="">
<input type="hidden" name="Submitted" value="1" />
</form>
</html>
<?PHP
}
?>