Ciao a tutti, sto sviluppando un sito in Joomla ma non riesco ad inviare e-mail.
Ecco il codice del file php che si trova nella cartella principale del sito e della form scritto in un articolo di joomla:
FORM
<form action="sendmail.php" method="post">
<table style="width: 95%;" border="0" cellspacing="15" cellpadding="15" align="center">
<tbody>
<tr>
<td colspan="3">
<div>MODULO RICHIESTA PREVENTIVI </div>
</td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td width="16%">Nome</td>
<td colspan="2" width="84%"><input name="nome" type="text" /></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td>Cognome</td>
<td colspan="2"><input name="cognome" type="text" /></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td>Società</td>
<td colspan="2"><input name="societa" type="text" /></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td>Città </td>
<td colspan="2"><input name="citta" type="text" /></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td>Provincia</td>
<td colspan="2"><input name="provincia" type="text" /></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td>Indirizzo E-mail </td>
<td colspan="2"><input name="mail" type="text" /></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td>Testo</td>
<td colspan="2"><textarea cols="40" rows="10" name="testo"></textarea></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td colspan="3">Richiesta preventivo per: </td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td width="33%"><input name="hosting" type="checkbox" value="y" />Hosting</td>
<td width="33%"><input name="sito" type="checkbox" value="y" />Sito Web</td>
<td width="33%"><input name="pcaccessori" type="checkbox" value="y" />Computer & Accessori</td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td width="33%"><input name="reti" type="checkbox" value="y" />Reti Aziendali</td>
<td width="33%"><input name="privacy" type="checkbox" value="y" />Consulenza Privacy</td>
<td width="33%"><input name="pec" type="checkbox" value="y" />Pec</td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td width="33%"><input name="assistenza" type="checkbox" value="y" />Contratto Assistenza</td>
<td width="33%"><input name="ufficio" type="checkbox" value="y" />Apertura Nuovo Ufficio</td>
<td width="33%"><input name="noleggio" type="checkbox" value="y" />Noleggio Stampanti</td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td>
<div><input class="button" name="submit" type="submit" value="Invia" /></div>
</td>
<td colspan="2">
<div><input class="button" name="reset" type="reset" value="Cancella" /></div>
</td>
</tr>
</tbody>
</table>
</form>
SENDMAIL.PHP
<?php
class maildeliver{
public $to="paolo.posta@tiscali.it";// L'INDIRIZZO DEL DESTINATARIO DELLA MAIL
public $oggetto="Richiesta preventivo dal sito www.vcom.it";// IL SOGGETTO DELLA MAIL
public $body='';
public function aggrega($name,$surname,$firm,$city,$province,$emai l,$preventive,$text){
$body= "Gentile Azienda, rilascio i dati per il seguente preventivo:\n\n";
$body.= "
Nome: ".trim(stripslashes($name)) . "
";
$body.= "Nognome: ".trim(stripslashes($surname)) . "
";
$body.= "Società: ".trim(stripslashes($firm)) . "
";
$body.= "Città: ".trim(stripslashes($city)) . "
";
$body.= "Provincia: ".trim(stripslashes($province)) . "
";
$body.= "E-mail: ".trim(stripslashes($email)) . "
";
$body.= "Preventivo per: ".(stripslashes($preventive)) . "
";
$body.= "Descrizione: ".trim(stripslashes($text)). "
";
}
public function sendmail() {
$mail=mail($to,$oggetto,$body);
return $mail;
}
}//end class
// Tipo Preventivo
$tipo = array('Hosting ','Sito Web ','PC e Accessori ','Reti Aziendali ','Consulenza Privacy ','Posta Elettronica Certificata ','Contratto Assistenza ','Apertura nuovo Ufficio ','Noleggio Stampanti ');
$value = array('hosting','sito','pcaccessori','reti','priva cy','pec','assistenza','ufficio','noleggio');
$prev='';
for ($i=0;$i<8;$i++) {
if ($_POST[$value[$i]] != null)
$prev .= $tipo[$i];
}
$prev = str_replace(" ","; ",$prev);
$email=new maildeliver();
$email->aggrega($_POST["nome"],$_POST["cognome"],$_POST["societa"],$_POST["citta"],$_POST["provincia"],$_POST["mail"],$prev,$_POST["testo"]);
// COSTRUZIONE DEL CORPO DEL MESSAGGIO
//$body .= "Gentile Azienda, rilascio i dati per il seguente preventivo:\n\n";
/*$body .= "
Nome: " . trim(stripslashes($_POST["nome"])) . "
";
$body .= "Nognome: " . trim(stripslashes($_POST["cognome"])) . "
";
$body .= "Società: " . trim(stripslashes($_POST["societa"])) . "
";
$body .= "Città: " . trim(stripslashes($_POST["citta"])) . "
";
$body .= "Provincia: " . trim(stripslashes($_POST["provincia"])) . "
";
$body .= "E-mail: " . trim(stripslashes($_POST["mail"])) . "
";
$body .= "Preventivo per: " . (stripslashes($prev)) . "
";
$body .= "Descrizione: " . trim(stripslashes($_POST["testo"])) . "
";*/
//$mail = trim(stripslashes($_POST["mail"]));
//$mail = trim(stripslashes($_POST["mail"]));
//if (isset($_POST['nome']) || isset($_POST['email']) || isset($_POST['messaggio'])) {
// $nome=$_POST['nome'];
//$email=$_POST['email'];
//$testo=$_POST['messaggio'];
//$oggetto="Messaggio dal sito www.giustecreazioni.com";
//if(($nome != "") && ($email != "") && ($testo != "")) {
//$from="From:".$nome."<".$email.">"."";
//$mail=mail($to,$oggetto,$body);
$esito=$email->sendmail();
//}
if(!$esito){
echo "<script type='text/javascript'>";
echo "alert('E-mail non inviata. Riprova!');";
echo "location.href = 'javascript:history.back();';";
echo "</script>";
}
else {
echo "<script type='text/javascript'>";
echo "alert('Messaggio inviato');";
echo "location.href = 'javascript:history.back();';";
echo "</script>";
}

