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 = '

수신 : ' . $vendorName . '


' . $sendCompany . '(으)로부터 ' . $item . '(이)가 도착하였습니다.


보낸회사 ' . $sendCompany . ' 발행일자 ' . $issueDate . '
Email ' . $email . ' 연락처 ' . $phone . '
메모
'; $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); ?>