This question already has an answer here:
I am having a problem sending an email to the following domains:
@yahoo.com,
@hotmail.com, and
@mncgroup.com
using the PHP mail() function. But there's no problem if I send an email to @gmail.com
Is there something wrong with my code?
$to = "$email";
$subject = "[NO-REPLY]Confirmation Account Pengaduan Keluhan I-news Tv";
$header = "From: inewsit@mncgroup.com
";
$header .= "Akun Information MNC Biro";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";
$message = "<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>Selamat Akun Anda Sudah Aktif</h1>
<p>Detail Account Username :</p>
<br>Your username : $hasil[username]
<br> Your Full Name : $hasil[nama]
<br> Your Email Address : $hasil[email]
<br> Your Status Akun : $status_akun1
<br> Your Lever authentication : $hasil[level]
<br> Your Register Date : $hasil[tanggal_register]
<br>Login sekarang ke : <a href='http://mncgroup.hol.es'><i>http://mncgroup.hol.es</i></a>
</body>
</html>";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
?>
<div class="alert alert-success alert-dismissable">
<a class="panel-close close" data-dismiss="alert">x</a>
<center>Silahkan Cek <strong>Email</strong> Anda</center>
</div>
<?php
when i run this code and i try to send email to 3 domain above, the message does not get into the email
</div>
First, try this in your code:
echo (mail($to, $subject, $message, $headers)) ? 'Message sent!' : 'Message not sent!';
Because of mail()
function returns true or false
depending on whether the mail was accepted for delivery. I recommend you check your spam folder at those addresses. I have heard that mail sent from the free servers due to the amount of abuse goes directly to spam.
Try this sample code for checking purpose:
<?php
$to = 'ANY EMAIL@yahoo.com';
$subject = 'ANY SUBJECT';
$message = 'ANY MESSAGE';
$headers = 'From: check@check.com' . "
" .
'Reply-To: no-reply@check@check.com' . "
" .
'X-Mailer: PHP/' . phpversion();
echo (mail($to, $subject, $message, $headers)) ? 'Message sent!' : 'Message not sent!';
?>
Try replacing all occurrences of with PHP_EOL. Something like this:
$to = "$email";
$eol = PHP_EOL;
$subject = "[NO-REPLY]Confirmation Account Pengaduan Keluhan I-news Tv";
$header = "From: inewsit@mncgroup.com $eol";
$header .= "Akun Information MNC Biro";
$headers .= "MIME-Version: 1.0$eol";
$headers .= "Content-Type: text/html; charset=ISO-8859-1$eol";
See if that changes anything.