본문으로 바로가기

원인 

전송하는 본문내용이 1000자가 넘어가면 발생.

 

<?
header('Content-Type: text/html; charset=UTF-8');

//받는 메일 주소
$to_mail = isset($_REQUEST['to_mail']) ? $_REQUEST['to_mail'] : '';

//받는 사람
$to_name = isset($_REQUEST['to_name']) ? $_REQUEST['to_name'] : '';

//제목
$to_subject = isset($_REQUEST['to_subject']) ? $_REQUEST['to_subject'] : '';

//내용
$to_content = isset($_REQUEST['to_content']) ? $_REQUEST['to_content'] : '';
$to_content = chunk_split(base64_encode($to_content));

//보내는 메일
$from_mail = isset($_REQUEST['from_mail']) ? $_REQUEST['from_mail'] : '';

//숨은 참조
$bcc_mail = "참조받을 이메일";

if ($to_mail && $to_subject && $to_content){
    $to      = $to_mail;
    $subject = "=?UTF-8?B?".base64_encode($to_subject)."?=";
    $content = $to_content;
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=utf-8\r\n";
    $headers .= "Content-Transfer-Encoding: base64\r\n";
    $headers .= "From:". $from_mail . "\r\n" .
        "Bcc:". $bcc_mail . "\r\n" .
        "Reply-To:". $from_mail . "\r\n" .
        "X-Mailer: PHP/" . phpversion();
    
    mail($to, $subject, $content, $headers);

    echo '{"stats":true, "msg":"전송완료"}';
    exit;
}else{
    echo '{"stats":false, "msg":"필수항목 누락"}';
    exit;
}
?>

 

 

내용에 chunk_split(base64_encode($to_content) 추가

해더에 Content-Transfer-Encoding: base64\r\n 추가

'[ Web 관련 ] > php' 카테고리의 다른 글

php curl에서 proxy 사용 + 이미지를 Base64 변환  (0) 2020.03.19
php 날짜 더하기 (날짜 계산)  (0) 2020.02.14
php 상수 사용  (0) 2020.01.07
php 자리수 맞게 0 채우기  (0) 2020.01.07
php 두 개의 배열 다루기  (0) 2020.01.07