Utilizzo un semplice HTML. Ho problema con un form in quanto vorrei utilizzare un mio account smtp, ma non riesco a farlo e vi presento il problema:
1. Ho creato al link http://www.auroramincuzzi.it/Contatti.html
un form con il seguente codice:
Codice PHP:
<form action="mail.php" method="post" enctype="multipart/form-data" id="ContactForm"> <div> <label><input type="text" name="name" value="Name:" class="input" /></label> <label><input type="text" name="mail" value="E-mail:" class="input" /></label> <textarea cols="30" rows="10" name="msg">Message:</textarea> <div class="container"> <div class="right"> <div class="right">[url="#"]<span>submit</span>[/url]</div> <div class="right padd2">[url="#"]<span>reset</span>[/url]</div> <input type="submit" name="button" id="button" value="Submit" /> </div> </div> </div> </form>
2. una volta compilato il form esso richiama il mail.php che ha questo script:
codice:
<? require_once("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // attiva l'invio tramiteSMTP $mail->Host = "mail.inwind.it"; // indirizzo smtp $mail->From = $mail; $mail->FromName = $name; $mail->AddAddress("xxx@xxxxx.it"); $mail->IsHTML(true); $mail->Body = $msg; if(!$mail->Send()){ echo "Si è verificato un errore nell'invio della mail"; }else{ echo "Mail inviata con successo"; } ?>
3 che a sua volta chiama il file class.phpmailer.php di phpmailer.
la funzione Send è questa:
Codice PHP:
function Send() { $header = ''; $body = ''; $result = true; if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { $this->SetError($this->Lang('provide_address')); return false; } /* Set whether the message is multipart/alternative */ if(!empty($this->AltBody)) { $this->ContentType = 'multipart/alternative'; } $this->error_count = 0; // reset errors $this->SetMessageType(); $header .= $this->CreateHeader(); $body = $this->CreateBody(); if($body == '') { return false; } /* Choose the mailer */ switch($this->Mailer) { case 'sendmail': $result = $this->SendmailSend($header, $body); break; case 'smtp': $result = $this->SmtpSend($header, $body); break; case 'mail': $result = $this->MailSend($header, $body); break; default: $result = $this->MailSend($header, $body); break; //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported')); //$result = false; //break; } return $result; }
Non riesco ad inviare, perchè?
grazie