1
I am desperately trying to send an email via PHP, according to the code below. But the code breaks when I enter HTML, example:
$mensagem = "<html> (...) </html>";
I’m gonna need a whole page in there! I’ve tried too:
// Abre o template...
$corpoDoEmail = file_get_contents(index.txt');
//E troca as variáveis
$corpoDoEmail = str_replace( '%NOME%', $nome, $corpoDoEmail );
But it doesn’t work, it doesn’t bring any data.
<?php
$para = "[email protected]";
$nome = $_POST['nome'];
$assunto = "Ebah! Temos um novo usuário!";
$mensagem = "<strong>Nome: </strong>".$nome;
$mensagem .= "<br><br>O usuário: ".$_POST['nome'];
$mensagem .= " quer receber nosso e-mail de Bem Vindo!";
QUERO O CONTEÚDO HTML AQUI
$headers = "Content-Type:text/html; charset=UTF-8\n";
$headers .= "From: Golleo<[email protected]>\n";
$headers .= "X-Sender: <[email protected]>\n";
$headers .= "X-Mailer: PHP v".phpversion()."\n";
$headers .= "X-IP: ".$_SERVER['REMOTE_ADDR']."\n";
$headers .= "Return-Path: <[email protected]>\n";
$headers .= "MIME-Version: 1.0\n";
mail($para, $assunto, $mensagem,
$headers);
?>
Receive email with no content?
– Silvio Andorinha
I get only what is declared in "$message", but wanted to put an entire html page, so email have a more beautiful layout!
– Gabriel
Ahhh, you receive the e-mail without formatting
– Silvio Andorinha
Actually, I want to e-mail this full page: http://golleo.com.br/developer/workspace/golleosignupmail/index.html
– Gabriel
@Gabriel remove the DOCTYPE and the tags html, head, meta, title, script and body. Some email services block messages that contain these tags because they may modify the default behavior of the email service.
– Clayderson Ferreira
Possible duplicate of How to pick up a form and send it to e-mail?
– joao dias