헤더 설정시 약간의 문제가 있습니다. 가장 중요한 것은 From
섹션에 올 바르고 유효한 이메일 아이디를 정의해야한다는 것입니다. 구글이 일반적으로 도메인의 유효성 확인에 사용했기 때문입니다.
google 엔드에 흰색으로 표시되지 않으면 메일이 자동으로 스팸으로 종료됩니다.
PHP 메일 기능이 잘 구성된 SMTP 서버를 사용하지 않는 문제는 간단합니다. 요즘 전자 메일 클라이언트와 서버는 Reverse DNS 조회, Graylisting 및 whatev와 같이 서버를 보내는 전자 메일에 대한 대규모 검사를 수행합니다. 이 모든 테스트는 php mail() 함수와 함께 실패합니다. 유동 IP를 사용하고 있다면, PHPMailer-Class를 사용하고 잘 구성된 전용 SMTP 서버 (로컬 서버 또는 원격 서버)와 함께 smtp-auth를 사용하도록 구성하면 문제가
입니다
아래 코드를 시도해 볼 수 있습니다.
$headers = "From: [email protected]\r\n";
$headers .= "Reply-To: [email protected]\r\n";
$headers .= "Return-Path: [email protected]\r\n";
$headers .= "CC: [email protected]\r\n";
$headers .= "BCC: [email protected]\r\n";
참조 링크. 대신 at.mail
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) {
$file = $path.$filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$header = "From: ".$from_name." <".$from_mail.">\r\n";
$header .= "Reply-To: ".$replyto."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed;boundary=\"".$uid."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-type:text/plain;charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $message."\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-Type: application/octet-stream;name=\"".$filename."\"\r\n";
// use different content types here$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment;filename=\"".$filename."\"\r\n\r\n";
$header .= $content."\r\n\r\n";
$header .= "--".$uid."--";
if (mail($mailto, $subject, "", $header)) {echo "mail send ... OK";
// or use booleans here} else {echo "mail send ... ERROR!";
}
}
사용 메일 기능 기능은 모든 경고를 포기하지 않습니다 at.mail/오류가 당신에게 스팸 메일을 확인 – user3099298
: https://github.com/PHPMailer/PHPMailerPHPMailer/PHPMailerPHPMailer
당신이 시도 할 수있는 또 다른 코드가있다. – Veer
정확한 From Mail Id를 언급해야합니다. 나는 며칠 전 같은 문제에 직면했다. –