Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,19 @@
|
|
| 1 |
-
import
|
| 2 |
-
import socket
|
| 3 |
-
import threading
|
| 4 |
-
import time
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
break
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 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()
|
|
|
|
| 1 |
+
from django.core.mail import get_connection
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
# Create a mail connection
|
| 4 |
+
connection = get_connection()
|
| 5 |
|
| 6 |
+
# Define a view to receive emails
|
| 7 |
+
def receive_email(request):
|
| 8 |
+
if request.method == 'POST':
|
| 9 |
+
# Get the email from the request
|
| 10 |
+
email = request.POST.get('email')
|
| 11 |
|
| 12 |
+
# Process the email
|
| 13 |
+
print(email['Subject'])
|
| 14 |
+
print(email['From'])
|
| 15 |
+
print(email['Body'])
|
|
|
|
| 16 |
|
| 17 |
+
return HttpResponse('Email received!')
|
| 18 |
+
else:
|
| 19 |
+
return HttpResponseNotAllowed(['POST'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|