네이버 STMP 메일 발송하기 위한 준비 과정이다.
2단계로 SMS 인증을 선택한 경우에는 SMTP 메일 발송을 위한 별도의 기기용 비밀번호를 추가로 설정해야 한다.





설정한 비밀번호를 구현한 코드에 넣어야 한다.
|
function email_send($to_email,$subject,$message){
$mail = new PHPMailer(true);
//$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail->Charset = 'UTF-8';
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.naver.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = 'jsk005@naver.com'; //SMTP username
$mail->Password = ''; //SMTP password (기기 비밀번호)
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
$mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
//Recipients
$mail->setFrom('jsk005@naver.com', '홍길동');
//foreach($recipients as $to_email){
$mail->addAddress($to_email); //Add a recipient
//}
$mail->addReplyTo('jsk005@naver.com', '홍길동');
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $message;
$mail->send();
}
|
728x90
'Web 프로그램 > PHP 응용 및 활용' 카테고리의 다른 글
| PDO 코드를 MySQLi 코드로 변경 처리 방법 (0) | 2023.09.08 |
|---|---|
| PHP 회원 form jQuery POST 처리 (0) | 2023.07.13 |
| PHP 일일 접속 통계 구현 코드 (0) | 2023.06.08 |
| PHP 날짜 차이 계산 및 활용 (0) | 2022.04.24 |
| Java 암호화 및 PHP 복호화 (0) | 2021.07.08 |