Skip to content

Instantly share code, notes, and snippets.

@pedrovasconcellos
Created September 27, 2018 22:35
Show Gist options
  • Save pedrovasconcellos/5ae06345e4ce063870335ac5c57b51be to your computer and use it in GitHub Desktop.
Save pedrovasconcellos/5ae06345e4ce063870335ac5c57b51be to your computer and use it in GitHub Desktop.
Email Trigger In Php
<?php
header('Content-Type: text/html; charset=utf-8');
ini_set('default_charset','UTF-8');
function acentuacao_assunto($string){ return '=?UTF-8?B?'.base64_encode($string).'?='; }
//https://vasconcellossolutions.com
//https://vasconcellos.site
$emailrecipient = "contact@corporation.com";
$senderemail = $_POST['email'];
$sender = $emailrecipient;
$name = $_POST['name'];
$subject = $_POST['subject'];
$text = $_POST['emailtext'];
$telephone = $_POST['telephone'];
$subject = $subject." - ".date("d/m/Y H:i");
$finaltext =
"E-mail: ".$senderemail."
Nome: ".$name."\n
Assunto: ".$subject."
Telefone: ".$telephone."\n
Mensagem: \n".$text."\n\n
Enviado: ".date("d/m/Y H:i")."";
$headers = "From: $senderemail\r\n";
$headers .= "Reply-To: $senderemail\r\n";
$envio = mail($emailrecipient,acentuacao_assunto($subject), $finaltext, $headers);
if($envio) {
echo '<script> alert("Formulário enviado com sucesso!");
window.location.assign("index.html");
</script>';
}
else {
echo '<script> alert("Falha ao enviar o Formulário.");
window.location.assign("index.html");
</script>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment