ola tenho um site onde preciso de um formulario para a pagina suporte ou seja q seria preenchido nome,email ea mensagem e todo caisse no email, testei o email enviando direto esta funcionando normal, meu dominio e da locaweb, no site nao gera nenhum erro porém nunca chega o email
segue os codigos:
suporte.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Formulário de Contato</title>
<style type="text/css">
#contato {
font-family: Arial, Helvetica, sans-serif;
}
#contato input, #contato textarea {
font-family: Arial, Helvetica, sans-serif;
padding: 5px;
width: 250px;
}
</style>
</head>
<body>
<form action="envia.php" method="post" id="contato">
<fieldset>
<legend>Contact Form</legend>
<label>Your name:</label><br />
<input name="nome" type="text" /><br /><br />
<label>Your email:</label><br />
<input name="email" type="text" /><br /><br />
<label>STEAM_ID:</label><br />
<input name="assunto" type="text" /><br /><br />
<label>Message:</label><br />
<textarea name="mensagem" rows="10"></textarea><br /><br />
<input name="submit" type="submit" value="Submit" style="width: auto;" />
</fieldset>
</form>
</body>
envia.php
<?php
include_once('phpmailer.php'); //Chama o arquivo phpmailer.php com as funções para realizar o envio.
//#########################################
// Recebe as informações do formulário
//#########################################
$nome = $_POST['nome'];
$email = $_POST['email'];
$assunto = $_POST['assunto'];
$mensagem = $_POST['mensagem'];
//#########################################
// Dados da conta de e-mail que fará o envio
//#########################################
$smtp = new Smtp("localhost"); //Endereço do SMTP, geralmente localhost.
$smtp->user = "
[email protected]"; //Conta de email
$smtp->pass = "senha"; //Senha da Conta de e-mail.
$smtp->debug = false; //Somente para usuários avançados que desejam o log do envio para testes.
//#########################################
// Envio do formulário
//#########################################
$to = "
[email protected]"; //Informe aqui o e-mail que deve receber a mensagem do formulário.
$from = $email;
$subject = "Contato - " . $assunto;
$msg = $mensagem;
if (isset($_POST['submit'])) {
if($nome && $email && $assunto && $mensagem) {
if($smtp->Send($to, $from, $subject, $msg)){
echo "<script>alert('Message sent!');</script>";
echo "<script>window.location = 'index.php';</script>"; //Altere aqui para o endereço de sua página.
exit;
}
}
else {
echo "<script>alert('Fill in all fields!');</script>";
echo "<script>window.location = 'suporte.php';</script>"; //Altere aqui para o endereço de seu formulário
exit;
}
}
?>
[/code]
phpmailer.php
<?php
class Smtp{
var $conn;
var $user;
var $pass;
var $debug = false;
function Smtp($host){
$this->conn = fsockopen($host, 25, $errno, $errstr, 30);
$this->Put("EHLO $host");
}
function Auth(){
$this->Put("AUTH LOGIN");
$this->Put(base64_encode($this->user));
$this->Put(base64_encode($this->pass));
}
function Send($to, $from, $subject, $msg){
$this->Auth();
$this->Put("MAIL FROM: " . $from);
$this->Put("RCPT TO: " . $to);
$this->Put("DATA");
$this->Put($this->toHeader($to, $from, $subject));
$this->Put("\r\n");
$this->Put($msg);
$this->Put(".");
$this->Close();
if(isset($this->conn)){
return true;
}else{
return false;
}
}
function Put($value){
return fputs($this->conn, $value . "\r\n");
}
function toHeader($to, $from, $subject){
$header = "Message-Id: <". date('YmdHis').".". md5(microtime()).".". strtoupper($from) ."> \r\n";
$header .= "From: <" . $from . "> \r\n";
$header .= "To: <".$to."> \r\n";
$header .= "Subject: ".$subject." \r\n";
$header .= "Date: ". date('D, d M Y H:i:s O') ." \r\n";
$header .= "X-MSMail-Priority: High \r\n";
return $header;
}
function Close(){
$this->Put("QUIT");
if($this->debug == true){
while (!feof ($this->conn)) {
echo fgets($this->conn) . "<br>\n";
}
}
return fclose($this->conn);
}
}
?>
[/code]