我正在使用邮件功能发送邮件。当我将邮件从Gmail ID发送到网络邮件时,它工作正常,反之亦然,但当我将其更改为Gmail ID到Gmail ID时,它无法正常工作。下面是我在谷歌中找到的代码。
$subject = 'subject';
$message = 'message';
$to = 'user@gmail.com';
$type = 'plain'; // or HTML
$charset = 'utf-8';
$mail = 'mobisheer433@gmail.com';
$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: 3'."\n";
$headers .= 'X-MSMail-Priority: Normal'."\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';
if(mail($to, $subject, $message, $headers))
echo 'sucess';