Fix Contact Form - Use mailcow network Postfix server successfully

This commit is contained in:
Wind
2026-02-15 06:22:45 +09:00
parent 998d733eb5
commit 66e18d23c9
3 changed files with 22 additions and 8 deletions

View File

@@ -76,7 +76,9 @@ if (contactSubmitBtn) {
try {
// Python FastAPI 엔드포인트로 요청
const response = await fetch('http://localhost:8001/api/contact', {
// 현재 페이지의 호스트를 사용
const apiUrl = `${window.location.protocol}//${window.location.hostname}:8001/api/contact`;
const response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'

View File

@@ -1 +1 @@
{"cpu_temp": "43", "nvme_temp": "35", "uptime_days": 2, "last_update": "06:16:01"}
{"cpu_temp": "42", "nvme_temp": "35", "uptime_days": 2, "last_update": "06:22:01"}

View File

@@ -48,15 +48,19 @@ class ContactForm(BaseModel):
async def send_contact_email(form: ContactForm):
"""Contact form email handler"""
try:
# SMTP 설정
smtp_server = "mailcowdockerized_postfix-mailcow_1" # Docker 네트워크 내 호스트명
smtp_port = 25 # 일반 포트 (요청할 때)
# SMTP 설정 - mailcow Postfix 서버
# Docker 네트워크 내에서는 서비스 이름으로 접근
smtp_server = "mailcowdockerized_postfix-mailcow_1"
smtp_port = 25
print(f"Attempting to connect to SMTP: {smtp_server}:{smtp_port}")
# 메시지 구성
msg = MIMEMultipart('alternative')
msg['Subject'] = f"[Contact Form] {form.name} - {form.company}"
msg['From'] = form.email
msg['From'] = "contact@hanmocnn.co.kr"
msg['To'] = "windpacer@hanmocnn.co.kr"
msg['Reply-To'] = form.email
# 텍스트 본문
text_body = f"""
@@ -69,7 +73,7 @@ Message:
{form.message}
---
Submitted from Contact Form
Submitted from Hanmo Contact Form
"""
# HTML 본문
@@ -94,12 +98,20 @@ Submitted from Contact Form
msg.attach(part2)
# SMTP 연결 및 메일 전송
print(f"Connecting to SMTP server...")
with smtplib.SMTP(smtp_server, smtp_port, timeout=10) as server:
print(f"Connected! Sending email...")
server.sendmail(
form.email,
"contact@hanmocnn.co.kr",
"windpacer@hanmocnn.co.kr",
msg.as_string()
)
print(f"Email sent successfully!")
return {
"success": True,
"message": "Your message has been sent successfully. We will get back to you soon."
}
return {
"success": True,