crystal99 commited on
Commit
91c1b4a
·
verified ·
1 Parent(s): 8102c9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -16
app.py CHANGED
@@ -1,19 +1,18 @@
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'])
 
1
+ import os
2
+ from django.core.mail import send_mail
3
 
4
+ from django.conf import settings
 
5
 
6
+ settings.configure(
7
+ EMAIL_BACKEND='django.core.mail.backends.console.EmailBackend',
8
+ # You can also add other settings like this
9
+ )
 
10
 
11
+ # Now Django knows where to find the settings
12
+ send_mail(
13
+ subject='Test Email',
14
+ message='This is a test email.',
15
+ from_email='from@hoof.icom',
16
+ recipient_list=['ssuujjooyysujoy@outlook.com'],
17
+ fail_silently=False,
18
+ )