Sending Email on Server

0

I'm trying to create a page that sends emails but I'm not getting them ...

Would you have something to check?

Here is the code I use to send ...

<?php
$message = "Testando outros remetentes, para facilitar a resposta";
$headers = 'From: [email protected]';

if (mail('[email protected]', 'Teste', $message, $headers)) {
    print('Funcionou');
}else{ 
    print('Nao Funcionou...');
};
?>

Should this FROM email be registered on my hosting panel server or can I use a generic?

    
asked by anonymous 27.06.2016 / 16:57

1 answer

1

Try this, the problem is often the headers default, you should define them, mainly From and Reply-To

$body = 'corpo da mensagem';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=utf-8" . "\r\n";
$headers .= "From: Miguel <[email protected]>" . "\r\n" .
"Reply-To: [email protected]" . "\r\n" .
"X-Mailer: PHP/" . phpversion();

if(!mail('[email protected]', 'teste', $body, $headers)) 
{
    echo 'Erro';
}
else {
    echo 'YAY';
}
    
27.06.2016 / 17:10