\x89PNG\r\n\x1a\n\x00\x00\x00\x0DIHDR\x00\x00\x00\x01\x00 \x00\x00\x01\x08\x06\x00\x00\x00\x1F\x15\xC4\x89\x00\x00\x00 \x0AIDATx\x9Ccb\x00\x00\x00\x06\x00\x03\x1A\x05\x9D\x00\x00 \x00\x00IEND\xAE\x42\x60\x82
| Path : /var/www/html/yedekle24/BackupShieldv1/ |
|
B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H |
| Current File : /var/www/html/yedekle24/BackupShieldv1/email_service.py |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import smtplib
import ssl
import sys
import os
import datetime
import time
import threading
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
# SMTP ayarları - sabit değerler
SMTP_HOST = 'mail.hepsibulutta.com'
SMTP_PORT = 587
SMTP_USER = 'yedekle24@hepsibulutta.com'
SMTP_PASSWORD = 'ooka5asd2mas2el1ai0eeC222'
FROM_EMAIL = 'yedekle24@hepsibulutta.com'
TO_EMAIL = 'gokhana@ofisbulutta.com'
# E-posta gönderme fonksiyonları
def log_to_file(message):
"""Mesajı bir dosyaya yazar"""
log_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logs')
os.makedirs(log_dir, exist_ok=True)
log_file = os.path.join(log_dir, f'email_log_{datetime.datetime.now().strftime("%Y%m%d")}.txt')
with open(log_file, 'a', encoding='utf-8') as f:
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
f.write(f"[{timestamp}] {message}\n")
def send_email_with_retry(name, email, subject, message, max_retries=3):
"""E-posta göndermeyi dener ve başarısız olursa tekrar dener"""
for attempt in range(1, max_retries + 1):
try:
log_to_file(f"Deneme {attempt}/{max_retries}: E-posta gönderimi başlatılıyor...")
# E-posta oluştur
msg = MIMEMultipart()
msg['From'] = FROM_EMAIL
msg['To'] = TO_EMAIL
msg['Subject'] = f"YedekleDB24 İletişim Formu: {subject}"
msg['Reply-To'] = f"{name} <{email}>"
# E-posta içeriği
current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
body = f"""
İletişim Formu Mesajı:
Ad Soyad: {name}
E-posta: {email}
Konu: {subject}
Mesaj:
{message}
---
Bu e-posta YedekleDB24 iletişim formundan gönderilmiştir.
Tarih/Saat: {current_time}
"""
msg.attach(MIMEText(body, 'plain'))
# SSL bağlantısı
log_to_file("SSL context oluşturuluyor...")
context = ssl.create_default_context()
# SMTP sunucusuna bağlan
log_to_file(f"SMTP sunucusuna bağlanılıyor: {SMTP_HOST}:{SMTP_PORT}...")
with smtplib.SMTP(SMTP_HOST, SMTP_PORT, timeout=30) as server:
log_to_file("Sunucuya bağlandı")
server.ehlo()
log_to_file("EHLO başarılı")
server.starttls(context=context)
log_to_file("TLS başlatıldı")
server.ehlo()
log_to_file("İkinci EHLO başarılı")
log_to_file(f"Giriş yapılıyor: {SMTP_USER}")
server.login(SMTP_USER, SMTP_PASSWORD)
log_to_file("Giriş başarılı")
log_to_file("E-posta gönderiliyor...")
server.send_message(msg)
log_to_file(f"E-posta başarıyla gönderildi: {TO_EMAIL}")
# Başarılı gönderim
return True
except Exception as e:
log_to_file(f"Hata oluştu (Deneme {attempt}/{max_retries}): {str(e)}")
import traceback
log_to_file(traceback.format_exc())
if attempt < max_retries:
wait_time = attempt * 2 # Her denemede bekle süresini artır
log_to_file(f"{wait_time} saniye bekleniyor ve yeniden denenecek...")
time.sleep(wait_time)
else:
log_to_file("Maksimum deneme sayısına ulaşıldı. Başarısız.")
return False
return False
def send_email_async(name, email, subject, message):
"""E-postayı arka planda gönderir"""
thread = threading.Thread(
target=send_email_with_retry,
args=(name, email, subject, message)
)
thread.daemon = True
thread.start()
return True
# Test kodu
if __name__ == '__main__':
test_name = "Test Kullanıcı"
test_email = "test@example.com"
test_subject = "Test Mesajı"
test_message = "Bu bir test mesajıdır. E-posta servisi testi."
print("E-posta gönderiliyor...")
result = send_email_with_retry(test_name, test_email, test_subject, test_message)
if result:
print("E-posta başarıyla gönderildi!")
else:
print("E-posta gönderilemedi!")