테스트 사이트 - 개발 중인 베타 버전입니다

폼메일 수신자 제목 이상 채택완료

sliverzero 1년 전 조회 1,254

폼메일을 사용하는데 제목이 이상하게 뜹니다..

왜 그럴까요..?
http://sir.kr/data/editor/2406/1025970347_1718241047.4438.png" width="653" />

 

</p>

<p><?php

ini_set('display_errors', 1);

ini_set('display_startup_errors', 1);

error_reporting(E_ALL);</p>

<p>require __DIR__ . '/lib/PHPMailer/src/PHPMailer.php';

require __DIR__ . '/lib/PHPMailer/src/Exception.php';

require __DIR__ . '/lib/PHPMailer/src/SMTP.php';</p>

<p>use PHPMailer\PHPMailer\PHPMailer;

use PHPMailer\PHPMailer\Exception;</p>

<p>include_once('./_common.php');

include_once(G5_CAPTCHA_PATH.'/captcha.lib.php');</p>

<p>if (!chk_captcha()) {

    alert('자동등록방지 숫자가 틀렸습니다.');

}</p>

<p>if (isset($_POST['email'])) {</p>

<p>    $email_to = "eseragh@gmail.com"; // 수신메일

    $email_subject = "[나무 속 자연공작소] {$_POST['first_name']} 님의 문의사항. {$_POST['mainlTitle']}";

    $email_subject = '=?UTF-8?B?' . base64_encode($email_subject) . '?=';</p>

<p>    if (!isset($_POST['first_name']) ||

        !isset($_POST['phone']) ||

        !isset($_POST['email']) ||

        !isset($_POST['mainlTitle']) ||

        !isset($_POST['comments']) ||

        !isset($_POST['agree'])) {

        die('Sorry.\nThere is a problem with the form you submitted.\nPlease check the form again.');

    }</p>

<p>    $first_name = $_POST['first_name']; // required

    $phone = $_POST['phone']; // not required

    $email = $_POST['email']; // required

    $comments = $_POST['comments']; // required

    $mainlTitle = $_POST['mainlTitle']; // required

    $group = isset($_POST['group']) ? implode(', ', $_POST['group']) : ''; // 다중체크

    $agree = $_POST['agree']; // required</p>

<p>    function clean_string($string) {

        $bad = array("content-type", "bcc:", "to:", "cc:", "href");

        return str_replace($bad, "", $string);

    }</p>

<p>    $email_message = "성명 : " . clean_string($first_name) . "

";

    $email_message .= "연락처 : " . clean_string($phone) . "

";

    $email_message .= "E-mail : " . clean_string($email) . "

";

    $email_message .= "제목 : " . clean_string($mainlTitle) . "

";

    $email_message .= "분야 : " . clean_string($group) . "

"; // 다중체크

    $email_message .= "문의 내용 : " . clean_string($comments) . "

";

    $email_message .= "개인정보처리방침 : " . clean_string($agree) . "

";</p>

<p>    // PHPMailer setup

    $mail = new PHPMailer(true);

    try {

        // Server settings

        $mail->isSMTP();

        $mail->Host = 'smtp.gmail.com';

        $mail->SMTPAuth = true;

        $mail->Username = 'eseragh@gmail.com'; // Your Gmail address

        $mail->Password = 'orqscwfrxfrxoenf'; // Your Gmail password or App Password

        $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;

        $mail->Port = 587;</p>

<p>        // Recipients

        $mail->setFrom('eseragh@gmail.com', '한국세라프');

        $mail->addAddress($email_to);</p>

<p>        // Content

        $mail->isHTML(true);

        $mail->Subject = $email_subject;

        $mail->Body = $email_message;</p>

<p>        $mail->send();

        // Use header for redirect after PHP execution

        header("Location: /home/sub04_04.php");

        exit();

    } catch (Exception $e) {

        echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";

    }

}

?>

 </p>

<p>

댓글을 작성하려면 로그인이 필요합니다.

답변 3개

채택된 답변
+20 포인트
플라이
1년 전

저 오류는 인코딩 오류로 보여집니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 4개

s
sliverzero
1년 전
인코딩이라는것이.. 저 코드 부분 오류가 아니라는 말씀이실까요..?
플라이
1년 전
[code]
$mail->setFrom('*** 개인정보보호를 위한 이메일주소 노출방지 ***', '한국세라프');
[/code]

이 부분에 발송시 이름이 깨지는 부분이 있다보니 이 부분을 iconv 함수로 인코딩을 변경해서 적용해 보셔야 한다는 부분입니다.
s
sliverzero
1년 전
코딩초보라서.. 이메일을 다른..iconv(?)로 바꾸라는것일까요?
$email_subject = '=?UTF-8?B?' . base64_encode($email_subject) . '?=';
이 부분은 상관없는걸까요?
s
sliverzero
1년 전
웹하드 용량 초과때문에 그런것같네요.. 답변달아주셔서 감사합니다

댓글을 작성하려면 로그인이 필요합니다.

R
1년 전

인코딩 체크하세요

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

성근
1년 전

제가 전에 이랬던 기억이 있는데 혹시 파일 열었을때 euc-kr로 저장하셨는지 확인한번 해보셔요
이전에 인코딩 맞추고 나서 해결됬던 기억이 있습니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

s
sliverzero
1년 전
인코딩이라는것이.. 저 코드 부분 오류가 아니라는 말씀이실까요..?

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인