Ho trovato questo form qui: http://php.html.it/script/vedi/4140/contact-form-10/ nella sezione php, che fa al caso mio, poichè dovevo creare un form con la possibilità di scegliere la persona e il settore a cui mandare la mail.
Tutto ok, con inclusioni e altro, e all'interno della root principale ho inserito i file della cartella contact, nella mia cartella contatti.
Il form è visibile, nel momento della spedizione sia i messaggi di errore che il resto sono ok....c'è solo un piccolo problema...le mail non partono!!!
Sto impazzendo da oggi pomeriggio alle due e non riesco a vedere il problema:
Posto il codice del documento contact.php:
<?php
include('contact_settings.php');
include('TemplateMailer.class.php');
$temp = new TemplateMailer();
$types = '';
foreach ($reasons as $type => $mail) {
$types .= "<option value=\"$type\">$type</option>\n";
}
$temp->assign('reasons',$types);
$disya = basename($_SERVER['PHP_SELF']);
$disya = str_replace('.php','.tpl.html',$disya);
$temp->assign("template_file",$disya);
$temp->preparemail($template_folder . $disya);
echo $temp->body;
?>
e poi quello delle due inclusioni, il primo quello in cui si settano gli indirizzi email:
<?php
//define project types and emails of persons in charge
$reasons = array(
"Responsabile Commerciale"=>"pippo@libero.it",
"Ufficio Acquisti"=>"pippo@libero.it",
"I want to offer business cooperation"=>"pippo@libero.it",
"I want to make a suggestion about this site"=>"pippo@libero.it",
"I was not answered to my previous request"=>"pippo@libero.it",
"Not defined in the list"=>"pippo@libero.it"
);
//specify folder with templates, with backslash at the end
$template_folder = './templates/';
//subject of email?
$email_subject = 'Contact from mydomain.com';
?>
poi quello in cui c'è la funzione con le varie directory:
<?php
class TemplateMailer {
var $body;
var $vars = array();
function assign($varname,$varvalue) {
$this->vars[$varname] = $varvalue;
}
function preparemail($template_file) {
$template = file_get_contents($template_file);
foreach ($this->vars as $key => $value) {
$template = str_replace('{$'.$key.'}',$value,$template);
}
$this->body = $template;
}
function send($from,$to,$subject,$headers) {
$sent = @mail($to,$subject,$this->body,"From: $from\r\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=utf-8\n" . $headers);
if ($sent) { return true; }
else { return false; }
}
}
?>
Se qualcuno può aiutarmi....GRAZIE![]()