이메일 보안 방법 1가지

이메일 보안 방법 중 제가 사용하고 있는 방법 입니다. 메일 주소를 웹에 노출시키지 않고 비밀번호를 입력 후 이메일 주소를 보여줍니다. 이 방법이 보안 상 좋은지 확실하지는 않지만 ChatGpt와 함께 만든 것입니다.

현재 Jukebox(쥬크박스) 라는 무료 음악듣기 사이트 하단에 적용 중입니다.

<!-- Direct email -->
<?php
    $email_address = "yourid@naver.com";
    $domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'example.com';
    $email_subject = "[" . $domain . "]-";
?>
<p>Free music is sourced from YouTube.<br>
Please leave your inquiries via <strong id='emailIcon'>E-mail</strong><strong id="emailAddress" class="highlight-email" style="display: none;"><a href="mailto:<?php echo $email_address; ?>?subject=<?php echo $email_subject; ?>"><?php echo $email_address; ?></a></strong>
</p>

<script>
    document.getElementById('emailIcon').addEventListener('click', function() {
        var securityCode = Math.floor(Math.random() * 9000) + 1000;
        alert('You need to enter a security code. Please remember this number: ' + securityCode);
        var inputCode = prompt('Enter security code');
        if (inputCode === null) {
            return; // if the user cancels the action
        }
        if (inputCode == securityCode) {
            document.getElementById('emailAddress').style.display = 'block';
            document.getElementById('emailIcon').style.display = 'none';
        } else {
            alert('Incorrect security code');
        }
    });
</script>
<!-- Direct email -->

댓글 남기기

0%