dpca4790 2014-10-05 17:43
浏览 40
已采纳

邮件PHP没有达到一半人[重复]

This question already has an answer here:

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("
", $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!

</div>
  • 写回答

2条回答 默认 最新

  • doudou5421 2014-10-05 17:52
    关注

    I would suggest to look into a mailer class for php like this one https://github.com/PHPMailer/PHPMailer

    saves you a lot of headaches

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了