Skip to content

Instantly share code, notes, and snippets.

@eliasfaical
Created July 4, 2013 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliasfaical/5928167 to your computer and use it in GitHub Desktop.
Save eliasfaical/5928167 to your computer and use it in GitHub Desktop.
Envio de e-mail com php
<?php
/*
* Template Name: Ajax Contato
*/
include_once('phpmailer/class.phpmailer.php');
if(isset($_POST['nome']) && isset($_POST['telefone']) && isset($_POST['email']) && isset($_POST['telefone']) && isset($_POST['mensagem'])){
$str_nome = trim($_POST['nome']);
$str_cidade = trim($_POST['cidade']);
$str_email = trim($_POST['email']);
$str_telefone = trim($_POST['telefone']);
$str_mensagem = trim($_POST['mensagem']);
$str_destino = "elias@eliasfaical.com";
$str_site = "www.eliasfaical.com";
$str_name = "Elias Faiçal";
$str_conteudo = "
<p>Foi feito um contato atr&aacute;s do website $str_site</p>
<strong>Nome: </strong>{$str_nome}
<br /><br />
<strong>cidade: </strong>{$str_cidade}
<br /><br />
<strong>E-mail: </strong>{$str_email}
<br /><br />
<strong>Telefone: </strong>{$str_telefone}
<br /><br />
<strong>Mensagem: </strong>{$str_mensagem}
";
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->SMTPDebug = false;
$mail->SMTPAuth = true;
$mail->Host = "smtp.eliasfaical.com";
$mail->Port = 587;
$mail->Username = "email@eliasfaical.com";
$mail->Password = "1234567";
$mail->From = "email@eliasfaical.com";
$mail->FromName = $str_name;
$mail->Subject = "Contato";
$mail->Body = $str_conteudo;
$mail->CharSet = "UTF-8";
$mail->IsHTML(true);
$mail->AddAddress( $str_destino, $str_site);
$msg = (!$mail->Send()) ? "<span class='erro'>A mensagem n&atilde;o pode ser enviada!</span>" : "<span class='sucesso'>Mensagem enviada com sucesso!</span>";
$mail->ClearAllRecipients();
$mail->ClearAttachments();
echo $msg;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment