I've got a website where people can register and need to validate in ordre to use their account. Unfortunately, some people are not receiving the confirmation mail..
here's the code I'm using
function mail_send($arr) {
if (!isset($arr['to_email'], $arr['from_email'], $arr['subject'], $arr['message'])) {
throw new HelperException('mail(); not all parameters provided.');
}
$to = empty($arr['to_name']) ? $arr['to_email'] : '"' . mb_encode_mimeheader($arr['to_name']) . '" <' . $arr['to_email'] . '>';
$from = empty($arr['from_name']) ? $arr['from_email'] : '"' . mb_encode_mimeheader($arr['from_name']) . '" <' . $arr['from_email'] . '>';
$headers = array
(
'MIME-Version: 1.0',
'Content-Type: text/html; charset="UTF-8";',
'Content-Transfer-Encoding: 7bit',
'Date: ' . date('r', $_SERVER['REQUEST_TIME']),
'Message-ID: <' . $_SERVER['REQUEST_TIME'] . md5($_SERVER['REQUEST_TIME']) . '@' . $_SERVER['SERVER_NAME'] . '>',
'From: ' . $from,
'Reply-To: ' . $from,
'Return-Path: ' . $from,
'X-Mailer: PHP v' . phpversion(),
'X-Originating-IP: ' . $_SERVER['SERVER_ADDR'],
);
mail($to, '=?UTF-8?B?' . base64_encode($arr['subject']) . '?=', $arr['message'], implode("\n", $headers));
}
$arr = array();
$arr['to_email'] = $mail;
$arr['from_email'] = "no-reply@website.com";
$arr['subject'] = "Welcome [Validation]";
$arr['message'] = 'Thank you for registering, you're now able to fully use this website.'."<br><br>".'Username: <b>'.$username.'</b> Password :<b>'.$password.'</b>.'."<br><br>".' You need to validate in order to login...'."<br>".'<a href="a">Validate!</a>'."<br><br>".'Have fun!'."<br><br>".'--- The team.';
mail_send($arr);
Also, I've got forum cms (phpbb and mybb) running great on the same server with 0 problem related to email..
So what's wrong with my code...
Thank you!