Ir para conteúdo
Fórum Script Brasil

colombara

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Tudo que colombara postou

  1. O problema é o seguinte: Se tem acento no nome e no assunto não recebo corretamente, porém no corpo do e-mail a acentuação chega tudo certo. Segue os arquivos para análise. FORMULARIO.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="novo-envia.php" method="post" id="contato"> <fieldset> <legend>Formulário de Contato</legend> <label>Seu nome:</label><br /> <input name="nome" type="text" /><br /><br /> <label>Seu email:</label><br /> <input name="email" type="text" /><br /><br /> <label>Assunto:</label><br /> <input name="assunto" type="text" /><br /><br /> <label>Mensagem:</label><br /> <textarea name="mensagem" rows="10"></textarea><br /><br /> <input name="submit" type="submit" value="Enviar" style="width: auto;" /> </fieldset> </form> </body> </html> ENVIA.PHP <?php include_once('novo-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("smtp.xxx.com"); //Endereço do SMTP, geralmente localhost. $smtp->user = "xxx@xxx.com.br"; //Conta de email $smtp->pass = "xxx"; //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 = "yyy@yyy.com"; //Informe aqui o e-mail que deve receber a mensagem do formulário. $from = $email; $subject = "CONTATO " . $nome . $assunto; $msg = $mensagem; if (isset($_POST['submit'])) { if($nome && $email && $assunto && $mensagem) { if($smtp->Send($to, $from, $subject, $msg)){ echo "<script>alert('Contato enviado!');</script>"; echo "<script>window.location = 'index.htm';</script>"; //Altere aqui para o endereço de sua página. exit; } } else { echo "<script>alert('Preencha todos os campos!');</script>"; echo "<script>window.location = 'novo-formulario.php';</script>"; //Altere aqui para o endereço de seu formulário exit; } } ?> 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); } } ?>
×
×
  • Criar Novo...