초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
26
email/get_companyCode.php
Normal file
26
email/get_companyCode.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
|
||||
$pdo = db_connect();
|
||||
|
||||
$secondordnum = $_POST['secondordnum'];
|
||||
|
||||
try {
|
||||
$sql = "SELECT email, vendor_name FROM {$DB}.phonebook WHERE secondordnum = ?";
|
||||
$stmh = $pdo->prepare($sql);
|
||||
$stmh->bindValue(1, $secondordnum, PDO::PARAM_STR);
|
||||
$stmh->execute();
|
||||
$row = $stmh->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row) {
|
||||
$response = array('email' => $row['email'], 'vendor_name' => $row['vendor_name']);
|
||||
} else {
|
||||
$response = array('error' => 'No data found', 'secondordnum' => $secondordnum );
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
} catch (PDOException $Exception) {
|
||||
echo json_encode(array('error' => $Exception->getMessage()));
|
||||
}
|
||||
?>
|
||||
89
email/naver_app_password_guide.php
Normal file
89
email/naver_app_password_guide.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>네이버 앱 비밀번호 생성 가이드</title>
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; margin: 20px; }
|
||||
.step { background: #f5f5f5; padding: 15px; margin: 10px 0; border-radius: 5px; }
|
||||
.important { background: #fff3cd; border: 1px solid #ffeaa7; padding: 15px; margin: 10px 0; border-radius: 5px; }
|
||||
.code { background: #2d3748; color: #e2e8f0; padding: 10px; border-radius: 3px; font-family: monospace; }
|
||||
.warning { background: #fed7d7; border: 1px solid #feb2b2; padding: 15px; margin: 10px 0; border-radius: 5px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>🔐 네이버 앱 비밀번호 생성 가이드</h1>
|
||||
|
||||
<div class="warning">
|
||||
<h3>⚠️ 현재 상황</h3>
|
||||
<p>SMTP 인증 오류가 발생했습니다. 네이버에서 앱 비밀번호를 요구하고 있습니다.</p>
|
||||
</div>
|
||||
|
||||
<h2>📋 단계별 설정 방법</h2>
|
||||
|
||||
<div class="step">
|
||||
<h3>1단계: 네이버 로그인</h3>
|
||||
<p><a href="https://nid.naver.com" target="_blank">https://nid.naver.com</a>에 접속하여 로그인합니다.</p>
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<h3>2단계: 보안 설정 접속</h3>
|
||||
<p>네이버 메인 → 우측 상단 프로필 클릭 → <strong>설정</strong> → <strong>보안</strong></p>
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<h3>3단계: 2단계 인증 활성화</h3>
|
||||
<p><strong>2단계 인증</strong> → <strong>활성화</strong> 클릭</p>
|
||||
<p>휴대폰 인증 또는 이메일 인증을 통해 2단계 인증을 설정합니다.</p>
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<h3>4단계: 앱 비밀번호 생성</h3>
|
||||
<p>2단계 인증 설정 후 → <strong>앱 비밀번호</strong> → <strong>새 앱 비밀번호 생성</strong></p>
|
||||
<p>앱 이름: <strong>경동기업 메일</strong> (또는 원하는 이름)</p>
|
||||
</div>
|
||||
|
||||
<div class="important">
|
||||
<h3>🎯 생성된 앱 비밀번호</h3>
|
||||
<p>16자리 영문+숫자 조합의 비밀번호가 생성됩니다.</p>
|
||||
<p>예시: <span class="code">abcd1234efgh5678</span></p>
|
||||
<p><strong>⚠️ 이 비밀번호를 안전한 곳에 복사해두세요!</strong></p>
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<h3>5단계: 코드 수정</h3>
|
||||
<p>생성된 앱 비밀번호를 <code>send_email.php</code> 파일의 <code>$password</code> 변수에 입력합니다.</p>
|
||||
<div class="code">
|
||||
$password = '생성된_앱_비밀번호_16자리';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<h3>6단계: 테스트</h3>
|
||||
<p>수정 후 <a href="test_email.php">테스트 페이지</a>에서 확인합니다.</p>
|
||||
</div>
|
||||
|
||||
<h2>🔧 대안 방법</h2>
|
||||
|
||||
<div class="step">
|
||||
<h3>방법 1: 네이버 메일 설정에서 SMTP 활성화</h3>
|
||||
<p>네이버 메일 → 설정 → POP3/SMTP 설정 → SMTP 사용 설정</p>
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<h3>방법 2: 다른 포트 사용</h3>
|
||||
<p>포트 587 (TLS) 또는 포트 25 (일반) 시도</p>
|
||||
</div>
|
||||
|
||||
<h2>📞 문제 해결</h2>
|
||||
<p>위 방법으로도 해결되지 않으면:</p>
|
||||
<ul>
|
||||
<li>네이버 고객센터: 1588-3660</li>
|
||||
<li>네이버 메일 고객센터: <a href="https://help.naver.com" target="_blank">https://help.naver.com</a></li>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
<p><em>마지막 업데이트: 2024년</em></p>
|
||||
</body>
|
||||
</html>
|
||||
68
email/php_info.php
Normal file
68
email/php_info.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
// PHP 7.3 환경 확인 파일
|
||||
// 이메일 설정 테스트 파일 (PHP 7.3 호환)
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
|
||||
|
||||
echo "<h2>PHP 7.3 환경 확인</h2>";
|
||||
echo "<p><strong>PHP 버전:</strong> " . PHP_VERSION . "</p>";
|
||||
|
||||
// 이메일 전송에 필요한 확장 모듈 확인
|
||||
$required_extensions = array(
|
||||
'openssl' => 'SSL/TLS 암호화 (SMTP 보안 연결)',
|
||||
'mbstring' => '멀티바이트 문자열 처리 (UTF-8 이메일)',
|
||||
'json' => 'JSON 처리 (API 응답)',
|
||||
'curl' => 'HTTP 요청 (선택사항)',
|
||||
'fileinfo' => '파일 정보 (첨부파일)'
|
||||
);
|
||||
|
||||
echo "<h3>필요한 PHP 확장 모듈:</h3>";
|
||||
echo "<table border='1' style='border-collapse: collapse; width: 100%;'>";
|
||||
echo "<tr><th>확장 모듈</th><th>상태</th><th>설명</th></tr>";
|
||||
|
||||
foreach ($required_extensions as $ext => $description) {
|
||||
$loaded = extension_loaded($ext);
|
||||
$status = $loaded ? "✅ 로드됨" : "❌ 로드되지 않음";
|
||||
$color = $loaded ? "green" : "red";
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td><strong>$ext</strong></td>";
|
||||
echo "<td style='color: $color;'>$status</td>";
|
||||
echo "<td>$description</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
|
||||
// SMTP 포트 확인
|
||||
echo "<h3>SMTP 포트 확인:</h3>";
|
||||
$smtp_ports = array(25, 465, 587);
|
||||
foreach ($smtp_ports as $port) {
|
||||
$connection = @fsockopen('smtp.naver.com', $port, $errno, $errstr, 5);
|
||||
if ($connection) {
|
||||
echo "<p>✅ 포트 $port: 연결 가능</p>";
|
||||
fclose($connection);
|
||||
} else {
|
||||
echo "<p>❌ 포트 $port: 연결 불가 ($errstr)</p>";
|
||||
}
|
||||
}
|
||||
|
||||
// 디렉토리 권한 확인
|
||||
echo "<h3>디렉토리 권한 확인:</h3>";
|
||||
$pdf_dir = $_SERVER['DOCUMENT_ROOT'] . '/pdfs/';
|
||||
echo "<p><strong>PDF 디렉토리:</strong> $pdf_dir</p>";
|
||||
echo "<p><strong>존재 여부:</strong> " . (is_dir($pdf_dir) ? "✅ 존재" : "❌ 없음") . "</p>";
|
||||
echo "<p><strong>쓰기 권한:</strong> " . (is_writable($pdf_dir) ? "✅ 쓰기 가능" : "❌ 쓰기 불가") . "</p>";
|
||||
|
||||
// PHPMailer 버전 확인
|
||||
if (class_exists('PHPMailer\PHPMailer\PHPMailer')) {
|
||||
echo "<h3>PHPMailer 정보:</h3>";
|
||||
echo "<p><strong>버전:</strong> " . PHPMailer::VERSION . "</p>";
|
||||
echo "<p><strong>상태:</strong> ✅ 정상 로드됨</p>";
|
||||
} else {
|
||||
echo "<h3>PHPMailer 정보:</h3>";
|
||||
echo "<p><strong>상태:</strong> ❌ 로드되지 않음</p>";
|
||||
}
|
||||
?>
|
||||
36
email/save_pdf.php
Normal file
36
email/save_pdf.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
if (isset($_POST['pdf']) && isset($_POST['filename'])) {
|
||||
$pdf = $_POST['pdf'];
|
||||
$filename = $_POST['filename'];
|
||||
$pdfDir = $_SERVER['DOCUMENT_ROOT'] . '/pdfs/';
|
||||
$filePath = $pdfDir . $filename; // 저장할 경로
|
||||
|
||||
try {
|
||||
// PDFs 디렉토리가 존재하는지 확인하고 없으면 생성
|
||||
if (!is_dir($pdfDir)) {
|
||||
if (!mkdir($pdfDir, 0755, true)) {
|
||||
throw new Exception("PDF 디렉토리를 생성할 수 없습니다: {$pdfDir}");
|
||||
}
|
||||
}
|
||||
|
||||
// 디렉토리 쓰기 권한 확인
|
||||
if (!is_writable($pdfDir)) {
|
||||
throw new Exception("PDF 디렉토리에 쓰기 권한이 없습니다: {$pdfDir}");
|
||||
}
|
||||
|
||||
// PDF 파일 저장
|
||||
$result = file_put_contents($filePath, base64_decode($pdf));
|
||||
|
||||
if ($result === false) {
|
||||
throw new Exception("PDF 파일 저장에 실패했습니다: {$filePath}");
|
||||
}
|
||||
|
||||
echo json_encode(array('success' => true, 'filename' => $filename));
|
||||
} catch (Exception $e) {
|
||||
error_log("PDF 저장 오류: " . $e->getMessage());
|
||||
echo json_encode(array('success' => false, 'error' => $e->getMessage()));
|
||||
}
|
||||
} else {
|
||||
echo json_encode(array('success' => false, 'error' => 'Invalid request - PDF data or filename missing'));
|
||||
}
|
||||
?>
|
||||
114
email/send_email.php
Normal file
114
email/send_email.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php'; // 운영 서버에서의 경로
|
||||
|
||||
// POST 데이터 안전하게 가져오기 (PHP 7.3 호환)
|
||||
$email = isset($_POST['email']) ? $_POST['email'] : '';
|
||||
$vendorName = isset($_POST['vendorName']) ? $_POST['vendorName'] : '';
|
||||
$filename = isset($_POST['filename']) ? $_POST['filename'] : ''; // 전달받은 파일명
|
||||
$item = isset($_POST['item']) ? $_POST['item'] : ''; // 거래명세표, 견적서, 총거래원장 등 선택
|
||||
$issueDate = isset($_POST['formattedDate']) ? $_POST['formattedDate'] : ''; // [24.07.30]형태의 날짜
|
||||
$sendCompany = '(주)경동기업';
|
||||
|
||||
function sendInvoiceEmail($to, $vendorName, $sendCompany, $issueDate, $item, $filename = null) {
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
$setFrom_email = 'kd5130@naver.com'; // 보내는 회사이메일
|
||||
$email = $setFrom_email ; // 보내는 회사이메일 표기되는 것
|
||||
// 네이버 SMTP 비밀번호 설정
|
||||
// 참고: 일부 계정은 기본 비밀번호로도 작동할 수 있습니다
|
||||
// 만약 인증 오류가 발생하면 앱 비밀번호를 사용하세요
|
||||
// 앱 비밀번호 생성: 네이버 설정 → 보안 → 2단계 인증 활성화 → 앱 비밀번호 생성
|
||||
$password = 'kd9835130'; // 메일 패스워드 (기본 비밀번호 또는 앱 비밀번호)
|
||||
$setFrom_company = $sendCompany ; // 보내는 회사
|
||||
$phone = '031-983-5130';
|
||||
|
||||
try {
|
||||
// SMTP 디버그 모드 활성화 (문제 해결 시에만 사용)
|
||||
// 0: 디버그 비활성화, 1: 클라이언트 메시지, 2: 클라이언트/서버 메시지, 3: 연결 정보 포함
|
||||
$mail->SMTPDebug = 0; // 문제 해결 시 2로 변경하여 상세 로그 확인
|
||||
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'smtp.naver.com';
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $setFrom_email;
|
||||
$mail->Password = $password;
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
||||
$mail->Port = 465;
|
||||
|
||||
// 타임아웃 설정 추가 (PHP 7.3 호환)
|
||||
$mail->Timeout = 30;
|
||||
$mail->SMTPKeepAlive = true;
|
||||
|
||||
$mail->CharSet = 'UTF-8';
|
||||
|
||||
$mail->setFrom($setFrom_email, $setFrom_company);
|
||||
$mail->addAddress($to);
|
||||
|
||||
// 첨부파일 추가
|
||||
if ($filename && !empty($filename)) {
|
||||
$filePath = $_SERVER['DOCUMENT_ROOT'] . '/pdfs/' . basename($filename); // 파일 경로
|
||||
|
||||
// 파일 존재 여부 및 권한 확인
|
||||
if (!file_exists($filePath)) {
|
||||
throw new Exception("첨부파일을 찾을 수 없습니다: {$filePath}");
|
||||
}
|
||||
|
||||
if (!is_readable($filePath)) {
|
||||
throw new Exception("첨부파일을 읽을 수 없습니다: {$filePath}");
|
||||
}
|
||||
|
||||
$mail->addAttachment($filePath);
|
||||
}
|
||||
|
||||
$mail->isHTML(true);
|
||||
$mail->Subject = '[' . $sendCompany . '](으)로부터 [' . $item . '](이)가 도착했습니다. ' . $issueDate;
|
||||
|
||||
// HTML 내용 작성
|
||||
$mail->Body = '
|
||||
<html>
|
||||
<body>
|
||||
<p>수신 : ' . htmlspecialchars($vendorName, ENT_QUOTES, 'UTF-8') . '</p> <br>
|
||||
<p>' . htmlspecialchars($sendCompany, ENT_QUOTES, 'UTF-8') . '(으)로부터 ' . htmlspecialchars($item, ENT_QUOTES, 'UTF-8') . '(이)가 도착하였습니다.</p>
|
||||
<br>
|
||||
<table border="1" style="border-collapse: collapse; width: 100%;">
|
||||
<tr>
|
||||
<th style="padding: 8px; text-align: left;">보낸회사</th>
|
||||
<td style="padding: 8px;">' . htmlspecialchars($sendCompany, ENT_QUOTES, 'UTF-8') . '</td>
|
||||
<th style="padding: 8px; text-align: left;">발행일자</th>
|
||||
<td style="padding: 8px;">' . htmlspecialchars($issueDate, ENT_QUOTES, 'UTF-8') . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="padding: 8px; text-align: left;">Email</th>
|
||||
<td style="padding: 8px;">' . htmlspecialchars($email, ENT_QUOTES, 'UTF-8') . '</td>
|
||||
<th style="padding: 8px; text-align: left;">연락처</th>
|
||||
<td style="padding: 8px;">' . htmlspecialchars($phone, ENT_QUOTES, 'UTF-8') . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="padding: 8px; text-align: left;">메모</th>
|
||||
<td style="padding: 8px;" colspan="3"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
$mail->AltBody = '수신 : ' . $vendorName . '\n' . $sendCompany . '(으)로부터 ' . $item . '(이)가 도착하였습니다.\n보낸회사: ' . $sendCompany . '\n발행일자: ' . $issueDate . '\nEmail: kd5130@naver.com\n연락처: 031-983-5130 \n메모:';
|
||||
|
||||
// 읽음 확인 설정
|
||||
$mail->addCustomHeader('Disposition-Notification-To', $setFrom_email);
|
||||
$mail->addCustomHeader('Return-Receipt-To', $setFrom_email);
|
||||
|
||||
$mail->send();
|
||||
echo json_encode(array('success' => true, 'message' => '메일이 전송되었습니다.'));
|
||||
} catch (Exception $e) {
|
||||
$errorMessage = "메일 전송 실패: " . $e->getMessage();
|
||||
error_log($errorMessage); // 서버 로그에 기록
|
||||
echo json_encode(array('success' => false, 'error' => $errorMessage));
|
||||
}
|
||||
}
|
||||
|
||||
sendInvoiceEmail($email, $vendorName, $sendCompany, $issueDate, $item, $filename);
|
||||
?>
|
||||
97
email/send_email_alternative.php
Normal file
97
email/send_email_alternative.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php'; // 운영 서버에서의 경로
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$email = $_POST['email'] ?? '';
|
||||
$vendorName = $_POST['vendorName'] ?? '';
|
||||
$filename = $_POST['filename'] ?? '' ; // 전달받은 파일명
|
||||
$item = $_POST['item'] ?? ''; // 거래명세표, 견적서, 총거래원장 등 선택
|
||||
$issueDate = $_POST['formattedDate'] ?? ''; // [24.07.30]형태의 날짜
|
||||
$sendCompany = '(주)경동기업';
|
||||
|
||||
function sendInvoiceEmail($to, $vendorName, $sendCompany, $issueDate, $item, $filename = null) {
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
$setFrom_email = 'kd5130@naver.com'; // 보내는 회사이메일
|
||||
$email = 'kd5130@naver.com'; // 보내는 회사이메일 표기되는 것
|
||||
$password = 'kd9835130'; // 대한 메일 패스워드
|
||||
$setFrom_company = '(주)경동기업'; // 보내는 회사
|
||||
$phone = '031-983-5130';
|
||||
|
||||
try {
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'smtp.naver.com';
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $setFrom_email;
|
||||
$mail->Password = $password;
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
||||
$mail->Port = 465;
|
||||
|
||||
$mail->CharSet = 'UTF-8';
|
||||
|
||||
$mail->setFrom($setFrom_email, $setFrom_company);
|
||||
$mail->addAddress($to);
|
||||
|
||||
// 첨부파일 추가
|
||||
if ($filename) {
|
||||
$filePath = $_SERVER['DOCUMENT_ROOT'] . '/pdfs/' . basename($filename); // 파일 경로
|
||||
if (file_exists($filePath)) {
|
||||
$mail->addAttachment($filePath);
|
||||
} else {
|
||||
echo json_encode(['error' => "File does not exist: {$filePath}" ]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$mail->isHTML(true);
|
||||
$mail->Subject = '[' . $sendCompany . '](으)로부터 [' . $item . '](이)가 도착했습니다. ' . $issueDate;
|
||||
|
||||
// HTML 내용 작성
|
||||
$mail->Body = '
|
||||
<html>
|
||||
<body>
|
||||
<p>수신 : ' . $vendorName . '</p> <br>
|
||||
<p>' . $sendCompany . '(으)로부터 ' . $item . '(이)가 도착하였습니다.</p>
|
||||
<br>
|
||||
<table border="1" style="border-collapse: collapse; width: 100%;">
|
||||
<tr>
|
||||
<th style="padding: 8px; text-align: left;">보낸회사</th>
|
||||
<td style="padding: 8px;">' . $sendCompany . '</td>
|
||||
<th style="padding: 8px; text-align: left;">발행일자</th>
|
||||
<td style="padding: 8px;">' . $issueDate . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="padding: 8px; text-align: left;">Email</th>
|
||||
<td style="padding: 8px;">' . $email . '</td>
|
||||
<th style="padding: 8px; text-align: left;">연락처</th>
|
||||
<td style="padding: 8px;">' . $phone . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="padding: 8px; text-align: left;">메모</th>
|
||||
<td style="padding: 8px;" colspan="3"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
$mail->AltBody = '수신 : ' . $vendorName . '\n' . $sendCompany . '(으)로부터 ' . $item . '(이)가 도착하였습니다.\n보낸회사: ' . $sendCompany . '\n발행일자: ' . $issueDate . '\nEmail: dhm2024@naver.com\n연락처: 010-3966-2024\n메모:';
|
||||
|
||||
// 읽음 확인 설정
|
||||
$mail->addCustomHeader('Disposition-Notification-To', $setFrom_email);
|
||||
$mail->addCustomHeader('Return-Receipt-To', $setFrom_email);
|
||||
|
||||
$mail->send();
|
||||
echo json_encode(['success' => '메일이 전송되었습니다.']);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['error' => "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"]);
|
||||
}
|
||||
}
|
||||
|
||||
sendInvoiceEmail($email, $vendorName, $sendCompany, $issueDate, $item, $filename);
|
||||
|
||||
?>
|
||||
106
email/test_basic_password.php
Normal file
106
email/test_basic_password.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
// 기본 비밀번호로 SMTP 연결 테스트
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
|
||||
|
||||
function testBasicPassword() {
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
try {
|
||||
// 디버그 모드 활성화
|
||||
$mail->SMTPDebug = 2;
|
||||
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'smtp.naver.com';
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = 'kd5130@naver.com';
|
||||
$mail->Password = 'kd9835130'; // 기본 비밀번호 테스트
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
||||
$mail->Port = 465;
|
||||
|
||||
$mail->CharSet = 'UTF-8';
|
||||
|
||||
echo "<h3>기본 비밀번호로 SMTP 연결 테스트</h3>";
|
||||
|
||||
// 연결 테스트
|
||||
$mail->smtpConnect();
|
||||
echo "<p style='color: green;'>✅ 기본 비밀번호로 연결 성공!</p>";
|
||||
|
||||
// 간단한 테스트 메일 전송 시도
|
||||
$mail->setFrom('kd5130@naver.com', '테스트');
|
||||
$mail->addAddress('kd5130@naver.com'); // 자기 자신에게 테스트
|
||||
$mail->Subject = 'SMTP 테스트';
|
||||
$mail->Body = '기본 비밀번호로 전송 테스트입니다.';
|
||||
|
||||
$mail->send();
|
||||
echo "<p style='color: green;'>✅ 기본 비밀번호로 메일 전송 성공!</p>";
|
||||
|
||||
} catch (Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
echo "<p style='color: red;'>❌ 오류: " . htmlspecialchars($error, ENT_QUOTES, 'UTF-8') . "</p>";
|
||||
|
||||
// 오류 메시지 분석
|
||||
if (strpos($error, '535') !== false || strpos($error, 'authentication') !== false) {
|
||||
echo "<p style='color: orange;'>⚠️ 인증 오류 - 앱 비밀번호가 필요할 수 있습니다.</p>";
|
||||
} elseif (strpos($error, 'connection') !== false) {
|
||||
echo "<p style='color: orange;'>⚠️ 연결 오류 - 네트워크 또는 포트 문제일 수 있습니다.</p>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testDifferentPorts() {
|
||||
echo "<h3>다양한 포트로 연결 테스트</h3>";
|
||||
|
||||
$ports = array(
|
||||
465 => 'SMTPS (SSL)',
|
||||
587 => 'SMTP (TLS)',
|
||||
25 => 'SMTP (일반)'
|
||||
);
|
||||
|
||||
foreach ($ports as $port => $description) {
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
try {
|
||||
$mail->SMTPDebug = 0; // 디버그 비활성화
|
||||
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'smtp.naver.com';
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = 'kd5130@naver.com';
|
||||
$mail->Password = 'kd9835130';
|
||||
|
||||
if ($port == 465) {
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
||||
} elseif ($port == 587) {
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
} else {
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
||||
}
|
||||
|
||||
$mail->Port = $port;
|
||||
$mail->CharSet = 'UTF-8';
|
||||
|
||||
$mail->smtpConnect();
|
||||
echo "<p style='color: green;'>✅ 포트 $port ($description): 연결 성공</p>";
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "<p style='color: red;'>❌ 포트 $port ($description): " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8') . "</p>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "<h2>네이버 SMTP 연결 테스트 (기본 비밀번호)</h2>";
|
||||
echo "<p><strong>테스트 계정:</strong> kd5130@naver.com</p>";
|
||||
echo "<p><strong>테스트 비밀번호:</strong> kd9835130</p>";
|
||||
|
||||
testBasicPassword();
|
||||
testDifferentPorts();
|
||||
|
||||
echo "<hr>";
|
||||
echo "<h3>결론:</h3>";
|
||||
echo "<p>1. 기본 비밀번호가 작동한다면 → 2단계 인증이 필요 없음</p>";
|
||||
echo "<p>2. 인증 오류가 발생한다면 → 앱 비밀번호 필요</p>";
|
||||
echo "<p>3. 연결 오류가 발생한다면 → 네트워크/포트 문제</p>";
|
||||
?>
|
||||
45
email/test_email.php
Normal file
45
email/test_email.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
// 이메일 설정 테스트 파일 (PHP 7.3 호환)
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
|
||||
|
||||
function testEmailConnection() {
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
try {
|
||||
// 디버그 모드 활성화
|
||||
$mail->SMTPDebug = 2;
|
||||
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'smtp.naver.com';
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = 'kd5130@naver.com';
|
||||
$mail->Password = 'kd9835130'; // 앱 비밀번호로 변경 필요
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
||||
$mail->Port = 465;
|
||||
|
||||
$mail->CharSet = 'UTF-8';
|
||||
|
||||
// 연결 테스트만 수행
|
||||
$mail->smtpConnect();
|
||||
echo "✅ SMTP 연결 성공!<br>";
|
||||
|
||||
// 인증 테스트
|
||||
if ($mail->smtpConnect()) {
|
||||
echo "✅ 인증 성공!<br>";
|
||||
} else {
|
||||
echo "❌ 인증 실패!<br>";
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "❌ 오류: " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8') . "<br>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<h2>네이버 SMTP 연결 테스트 (PHP " . PHP_VERSION . ")</h2>";
|
||||
echo "<p>현재 PHP 버전: " . PHP_VERSION . "</p>";
|
||||
echo "<p>PHPMailer 버전: " . PHPMailer::VERSION . "</p>";
|
||||
testEmailConnection();
|
||||
?>
|
||||
Reference in New Issue
Block a user