Email HTML
E aí galera, eu uso já faz um tempo, um código pra envio de email html, já tá formatadinho e tudo, no meu servidor local e algumas vezes (maioria) ele funciona certinho, mas algumas vezes não funciona.. e geralmente é nas coisas importantes que não funciona.. hehe... segue o código:
<? $nome = $_POST['nome']; $telefone = $_POST['telefone']; $endereco = $_POST['endereco']; $email = $_POST['email']; $mensagem = $_POST['mensagem']; $erros = ""; require_once("admin/inc/class.functions.php"); $functions = new Functions(); if ($functions->MailValidate($email) == false) { $erros .= "O e-mail digitado é inválido.<br />"; } if ($erros == "") { /////////////////////////////////////////////////////// $assunto="Contato Website"; // DEFINE O CORPO DA MENSAGEM $mensagem = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">](http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd) <html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml) <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { background-color: #a5b6d5; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } body,td,th { font-family: Tahoma; font-size: 11px; } table { height:200px; } .titulo { font-family:Arial; font-size: 14px; font-weight: bold; color: #FFFFFF; } --> </style> </head> <body> <br /><br /> <center><span class="titulo">Contato website</span></center><br /><br /> <table width="340" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#f3f3f4"> <tr> <td align="center" valign="top"> <table width="340" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20"> </td> <td width="300" align="left"> </td> <td width="20"> </td> </tr> <tr> <td width="20"> </td> <td width="300" align="left"> <b>Nome:</b><br />'.$nome.'<br /><br /> <b>Telefone:</b><br />'.$telefone.'<br /><br /> <b>Endereço:</b><br />'.$endereco.'<br /><br /> <b>Email:</b><br />'.$email.'<br /><br /> <b>Mensagem:</b><br />'.$mensagem.' </td> <td width="20"> </td> </tr> <tr> <td width="20"> </td> <td width="300" align="left"> </td> <td width="20"> </td> </tr> </table></td> </tr> </table> </body> </html>'; // DEFINE OS HEADERS $add = "MIME-Version: 1.0\r\n"; $add .= "Content-type: text/html; charset=iso-8859-1\r\n"; $add .= "From: Contato <admin@localhost>"; if (mail("admin@localhost",$assunto,$mensagem,$add)) { echo "<p class=\"texto_contato\">Sua mensagem foi enviada com sucesso. <br /><b>Obrigado por entrar em contato conosco.</b></p>"; } else { echo "<p class=\"texto_contato\">Ocorreu um erro ao enviar a sua mensagem. Tente novamente mais tarde.</p>"; } } else { echo "<p class=\"texto_contato\"><b>Ocorreram os seguintes erros:</b><br /><br />"; echo $erros; echo "Clique <a href=\"javascript:history.go(-1);\">Aqui</a> para voltar</p>"; } ///////////////////////////////////////////////////////?>Discussão (4)
Carregando comentários...