https://code.google.com/archive/a/apache-extras.org/p/phpmailer    다운로드


<?php


use PHPMailer\PHPMailer\PHPMailer;

use PHPMailer\PHPMailer\Exception;


require_once('./lib/PHPMailer-master/src/Exception.php');

require_once('./lib/PHPMailer-master/src/PHPMailer.php');

require_once('./lib/PHPMailer-master/src/SMTP.php');


$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch


$mail->IsSMTP(); // telling the class to use SMTP


try {


    $mail->Host = "smtp.gmail.com"; // email 보낼때 사용할 서버를 지정

    $mail->SMTPAuth = true; // SMTP 인증을 사용함

    $mail->Port = 465; // email 보낼때 사용할 포트를 지정

    $mail->SMTPSecure = "ssl"; // SSL을 사용함

    $mail->Username   = "test@gmail.com"; // Gmail 계정

    $mail->Password   = "password"; // 패스워드

    $mail->SMTPDebug = 2;

    $mail->CharSet = "utf-8";  //한글깨짐 방지를 위한 문자 인코딩설정

    $mail->SetFrom('test@gmail.com', 'TESTER'); // 보내는 사람 email 주소와 표시될 이름 (표시될 이름은 생략가능)

    $mail->AddAddress('test@naver.com', '받는사람'); // 받을 사람 email 주소와 표시될 이름 (표시될 이름은 생략가능)

    $mail->Subject = 'Email test'; // 메일 제목

    $mail->MsgHTML("mail test"); // 메일 내용 (HTML 형식도 되고 그냥 일반 텍스트도 사용 가능함)


    $mail->Send();


    echo "Message Sent OK";


}catch (phpmailerException $e) {

    echo $e->errorMessage(); //Pretty error messages from PHPMailer

} catch (Exception $e) {

    echo $e->getMessage(); //Boring error messages from anything else!

}

 ?>



+ Recent posts