0

我有这个工作正常的邮件功能,除了它总是以“垃圾”的形式到达。

我可以更改任何内容以使其到达“收件箱”吗?

另外我不确定它是否相关,但有时需要一些时间才能到达,有时似乎没有到达?

代码:

$subject = 'subject';
        $message = 'testingyesyes';
        $to = 'mail@chrismepham.com';
        $type = 'plain'; // or HTML
        $charset = 'utf-8';

        $mail     = 'no-reply@'.str_replace('www.', '', $_SERVER['SERVER_NAME']);
        $uniqid   = md5(uniqid(time()));
        $headers  = 'From: '.$mail."\n";
        $headers .= 'Reply-to: '.$mail."\n";
        $headers .= 'Return-Path: '.$mail."\n";
        $headers .= 'Message-ID: <'.$uniqid.'@'.$_SERVER['SERVER_NAME'].">\n";
        $headers .= 'MIME-Version: 1.0'."\n";
        $headers .= 'Date: '.gmdate('D, d M Y H:i:s', time())."\n";
        $headers .= 'X-Priority: 1'."\n";
        $headers .= 'X-MSMail-Priority: High'."\n";
        $headers .= 'Content-Type: multipart/mixed;boundary="----------'.$uniqid.'"'."\n\n";
        $headers .= '------------'.$uniqid."\n";
        $headers .= 'Content-type: text/'.$type.';charset='.$charset.''."\n";
        $headers .= 'Content-transfer-encoding: 7bit';

        mail($to, $subject, $message, $headers);

谢谢

4