我在向以下域发送电子邮件时遇到问题:
@yahoo.com,
@hotmail.com, and
@mncgroup.com
使用PHP mail()函数。但是,如果我发送电子邮件到@ gmail.com
,则没有问题我的代码有问题吗?
$to = "$email";
$subject = "[NO-REPLY]Confirmation Account Pengaduan Keluhan I-news Tv";
$header = "From: inewsit@mncgroup.com \r\n";
$header .= "Akun Information MNC Biro";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$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
当我运行此代码并尝试向上面的3个域发送电子邮件时,该消息不会进入电子邮件
答案 0 :(得分:0)
首先,在您的代码中尝试:
echo (mail($to, $subject, $message, $headers)) ? 'Message sent!' : 'Message not sent!';
由于mail()
函数返回true or false
,取决于邮件是否被接受传递。我建议您检查这些地址的垃圾邮件文件夹。我听说由于滥用的数量而从免费服务器发送的邮件直接发送到垃圾邮件。
尝试此示例代码以进行检查:
<?php
$to = 'ANY EMAIL@yahoo.com';
$subject = 'ANY SUBJECT';
$message = 'ANY MESSAGE';
$headers = 'From: check@check.com' . "\r\n" .
'Reply-To: no-reply@check@check.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
echo (mail($to, $subject, $message, $headers)) ? 'Message sent!' : 'Message not sent!';
?>
答案 1 :(得分:0)
尝试用PHP_EOL替换所有出现的\r\n
。像这样:
$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";
看看是否有任何改变。