Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,35 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import smtplib
|
| 2 |
+
import socket
|
| 3 |
+
import threading
|
| 4 |
+
import time
|
| 5 |
+
|
| 6 |
+
HOST = 'localhost' # Replace with your desired hostname
|
| 7 |
+
PORT = 25 # Standard SMTP port
|
| 8 |
+
|
| 9 |
+
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
| 10 |
+
server_socket.bind((HOST, PORT))
|
| 11 |
+
server_socket.listen()
|
| 12 |
+
|
| 13 |
+
def handle_client(client_socket, addr):
|
| 14 |
+
while True:
|
| 15 |
+
data = client_socket.recv(1024).decode()
|
| 16 |
+
if not data:
|
| 17 |
+
break
|
| 18 |
+
|
| 19 |
+
# Process received data (e.g., parse commands, send responses)
|
| 20 |
+
# ... (Implement your desired logic here)
|
| 21 |
+
|
| 22 |
+
# Example: Respond to HELO/EHLO command
|
| 23 |
+
if data.startswith('HELO') or data.startswith('EHLO'):
|
| 24 |
+
response = f'250 {HOST} Ready'
|
| 25 |
+
client_socket.send(response.encode())
|
| 26 |
+
|
| 27 |
+
client_socket.close()
|
| 28 |
+
|
| 29 |
+
while True:
|
| 30 |
+
client_socket, addr = server_socket.accept()
|
| 31 |
+
print('Connected by', addr)
|
| 32 |
+
|
| 33 |
+
# Create a separate thread to handle the client
|
| 34 |
+
client_thread = threading.Thread(target=handle_client, args=(client_socket, addr))
|
| 35 |
+
client_thread.start()
|