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

[최신버전] 구글 SMTP 설정을 통한 이메일 보내기]

· 2년 전 · 6555 · 12
images.jpg

이메일 보내기가 제대로 안되서 삽질하다가 정리한번 해봅니다.

 

1. 구글메일 설정- 보안- 2단계인증

982509662_1694272433.4776.png

 

2. 하단에 앱비밀번호 클릭

982509662_1694272470.5298.png

 

3.  앱선택 - 기타 맞춤이름 

 

982509662_1694272508.1056.png

 

4. 비밀번호 하나 생긴다. 

 

982509662_1694272570.2186.png

 

이렇게 만든 비밀번호를 입력한다 

 

/lib 폴더 밑으로 phpmailer 폴더를 넣으세요

[code]

<?php
//include_once "../_inc/_config.php";
include_once "./lib/PHPMailer/PHPMailerAutoload.php";

// 설정 변수
$digit = random_int(100000, 999999);
$fmail = "보내는메일";
// $fmail = "OOOOofficialmail@gmail.com";
$fname = "[OOO 고객센터]";
$mail_subject  = "[OOO] 회원인증메일";

$mail_content.='        <div id="mailform" style="padding: 30px 5%;">';
$mail_content.='            <div class="title" style="margin: 0 0 24px 0;"><span style="    display: inline-flex;
    padding: 0 0 20px 0;
    font-size: 20px;
    line-height: 1;
    color: #00b2a9;
    border-bottom: 2px solid #00b2a9;">New Account Registration Code</span></div>';
$mail_content.='            <div class="cont">';
$mail_content.='                <div class="tit" style="margin: 0 0 24px 0;
    font-size: 20px;
    font-weight: 600;
    color: #1c1c1c;">Welcome to OOOO!</div>';
$mail_content.='                <div class="txt" style="    font-size: 12px;
    margin: 0 0 32px 0;
    color: #1C1C1C;">Here’s your authentication code to create your OOOO account.<br>Please enter the code below now to verify this email address.</div>';
$mail_content.='                <div class="code" style="    display: block;
    flex-direction: column;
    margin: 0 0 40px 0;">';
$mail_content.='                    <span style="    margin: 0 0 10px 0;
    font-size: 12px;
    color: #000;">Code :</span>';
$mail_content.='                    <strong style="    display: block;
    height: 60px;
    font-size: 14px;
    color: #00b2a9;
    align-items: center;
    justify-content: center;
    background: #F6F6F6;
    line-height: 60px;
    text-align: center;">'.$digit.'</a>
    <div class="tit" style="margin: 0 0 24px 0;
        font-size: 14px;
        font-weight: 600;
        color: #1c1c1c;">위의 코드를 클릭하시면 인증이 완료됩니다.</div></strong>';
$mail_content.='                </div>';
$mail_content.='            </div>';
$mail_content.='        </div>';

$to = "받는사람 이메일";

if($to) {
    try {
        $mail = new PHPMailer(); // defaults to using php "mail()"

        $mail->IsSMTP(); // telling the class to use SMTP
        //$mail->SMTPDebug = 2;
        $mail->SMTPDebug  = SMTP::DEBUG_OFF;
        $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
        $mail->SMTPKeepAlive = true;
        $mail->Host          = 'smtp.gmail.com';
        $mail->Username = '구글계정';// 
        $mail->Password = '구글2단계 인증 앱비밀번호 입력란'; 
        // $mail->Port  = '587'; // SMTP server
        $mail->Port  = '465'; // SMTP server
        // $mail->SMTPSecure = 'tls';
        $mail->SMTPSecure = 'ssl';
        // $mail->Mailer = "smtp";
        $mail->CharSet = 'UTF-8';
        $mail->Encoding = 'base64';
        //$mail->AddEmbeddedImage('../logo.png', 'logo_2u');
        $mail->setFrom($fmail, $fname);
        $mail->addAddress($to);
        $mail->isHTML(true);
        $mail->Subject = $mail_subject;
        $mail->Body    = $mail_content;
        $result = $mail->send();
        
    } catch (Exception $e) {
        
    }
}else{
    
}

?>

[/code]

 

 

 

982509662_1694272824.013.png

 

      소소하게 유지보수 및 하자보수 해드립니다. 

 

      - 그누보드 / 영카트 부분,오류수정해드립니다.

      - 하이브리드 앱패키징 안드로이드 해드립니다. 

      - 퍼블리싱 가능합니다.

 

      카톡 : dev.megahit 

             

 

댓글 작성

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

로그인하기

댓글 12개

2년 전
이번 기회에 2차인증 비번 하는법도 배웠어요~~

첨부된 test.php 파일을 /lib 폴더 하위에 phpmailer란 폴더를 만들어 업로드하라는 건가요? 도무지 이해가 안되요...

게시글 목록

번호 제목
13945
13943
13939
13932
13931
13923
13911
13906
13891
13884
13873
13861