├── LICENSE ├── README.md ├── asyncproject ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-310.pyc │ ├── settings.cpython-310.pyc │ ├── urls.cpython-310.pyc │ └── wsgi.cpython-310.pyc ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py ├── backend ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-310.pyc │ ├── admin.cpython-310.pyc │ ├── apps.cpython-310.pyc │ ├── models.cpython-310.pyc │ ├── urls.cpython-310.pyc │ └── views.cpython-310.pyc ├── admin.py ├── apps.py ├── migrations │ ├── 0001_initial.py │ ├── __init__.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-310.pyc │ │ └── __init__.cpython-310.pyc ├── models.py ├── tests.py ├── urls.py └── views.py ├── db.sqlite3 ├── manage.py ├── requirements.txt └── templates └── index.html /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2022, Jumayev Ubaydullo 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ASYNC DJANGO EMAIL BACKEND 2 | 3 | async site built with Django (SUBUX) 4 | 5 | License: MIT 6 | 7 | OS: Ubuntu 22.04 8 | 9 | ## Settings 10 | 11 | - pip install -r requirements.txt 12 | 13 | -------------------------------------------------------------------------------- /asyncproject/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/asyncproject/__init__.py -------------------------------------------------------------------------------- /asyncproject/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/asyncproject/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /asyncproject/__pycache__/settings.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/asyncproject/__pycache__/settings.cpython-310.pyc -------------------------------------------------------------------------------- /asyncproject/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/asyncproject/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /asyncproject/__pycache__/wsgi.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/asyncproject/__pycache__/wsgi.cpython-310.pyc -------------------------------------------------------------------------------- /asyncproject/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for asyncproject project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'asyncproject.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /asyncproject/settings.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 4 | BASE_DIR = Path(__file__).resolve().parent.parent 5 | 6 | 7 | # Quick-start development settings - unsuitable for production 8 | # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ 9 | 10 | # SECURITY WARNING: keep the secret key used in production secret! 11 | SECRET_KEY = 'django-insecure-1r)092y)@pr2f&v_3$pp+jt%yrwngb!#1&b3&c2sg_ns433po-' 12 | 13 | # SECURITY WARNING: don't run with debug turned on in production! 14 | DEBUG = True 15 | 16 | ALLOWED_HOSTS = [] 17 | 18 | 19 | # Application definition 20 | 21 | INSTALLED_APPS = [ 22 | 'django.contrib.admin', 23 | 'django.contrib.auth', 24 | 'django.contrib.contenttypes', 25 | 'django.contrib.sessions', 26 | 'django.contrib.messages', 27 | 'django.contrib.staticfiles', 28 | 'backend', 29 | ] 30 | 31 | MIDDLEWARE = [ 32 | 'django.middleware.security.SecurityMiddleware', 33 | 'django.contrib.sessions.middleware.SessionMiddleware', 34 | 'django.middleware.common.CommonMiddleware', 35 | 'django.middleware.csrf.CsrfViewMiddleware', 36 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 37 | 'django.contrib.messages.middleware.MessageMiddleware', 38 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 39 | ] 40 | 41 | ROOT_URLCONF = 'asyncproject.urls' 42 | 43 | TEMPLATES = [ 44 | { 45 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 46 | 'DIRS': [ BASE_DIR / "templates" ], 47 | 'APP_DIRS': True, 48 | 'OPTIONS': { 49 | 'context_processors': [ 50 | 'django.template.context_processors.debug', 51 | 'django.template.context_processors.request', 52 | 'django.contrib.auth.context_processors.auth', 53 | 'django.contrib.messages.context_processors.messages', 54 | ], 55 | }, 56 | }, 57 | ] 58 | 59 | WSGI_APPLICATION = 'asyncproject.wsgi.application' 60 | 61 | 62 | # Database 63 | # https://docs.djangoproject.com/en/3.2/ref/settings/#databases 64 | 65 | DATABASES = { 66 | 'default': { 67 | 'ENGINE': 'django.db.backends.sqlite3', 68 | 'NAME': BASE_DIR / 'db.sqlite3', 69 | } 70 | } 71 | 72 | 73 | # Password validation 74 | # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators 75 | 76 | AUTH_PASSWORD_VALIDATORS = [ 77 | { 78 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 79 | }, 80 | { 81 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 82 | }, 83 | { 84 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 85 | }, 86 | { 87 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 88 | }, 89 | ] 90 | 91 | 92 | # Internationalization 93 | # https://docs.djangoproject.com/en/3.2/topics/i18n/ 94 | 95 | LANGUAGE_CODE = 'en-us' 96 | 97 | TIME_ZONE = 'UTC' 98 | 99 | USE_I18N = True 100 | 101 | USE_L10N = True 102 | 103 | USE_TZ = True 104 | 105 | 106 | # Static files (CSS, JavaScript, Images) 107 | # https://docs.djangoproject.com/en/3.2/howto/static-files/ 108 | 109 | STATIC_URL = '/static/' 110 | 111 | # Default primary key field type 112 | # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field 113 | 114 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 115 | 116 | # EMAIL_USE_TLS = True 117 | # EMAIL_HOST = 'smtp.gmail.com' 118 | # EMAIL_PORT = 587 119 | # EMAIL_HOST_USER = 'youremail@gmail.com' 120 | # EMAIL_HOST_PASSWORD = 'yourpassword' 121 | -------------------------------------------------------------------------------- /asyncproject/urls.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.urls import path, include 3 | 4 | urlpatterns = [ 5 | path('admin/', admin.site.urls), 6 | path('', include("backend.urls")) 7 | ] 8 | -------------------------------------------------------------------------------- /asyncproject/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for asyncproject project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'asyncproject.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /backend/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/backend/__init__.py -------------------------------------------------------------------------------- /backend/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/backend/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /backend/__pycache__/admin.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/backend/__pycache__/admin.cpython-310.pyc -------------------------------------------------------------------------------- /backend/__pycache__/apps.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/backend/__pycache__/apps.cpython-310.pyc -------------------------------------------------------------------------------- /backend/__pycache__/models.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/backend/__pycache__/models.cpython-310.pyc -------------------------------------------------------------------------------- /backend/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/backend/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /backend/__pycache__/views.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/backend/__pycache__/views.cpython-310.pyc -------------------------------------------------------------------------------- /backend/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /backend/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class BackendConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'backend' 7 | -------------------------------------------------------------------------------- /backend/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.3 on 2022-10-13 21:35 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Article', 16 | fields=[ 17 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('title', models.CharField(max_length=200)), 19 | ('description', models.TextField()), 20 | ('created_at', models.DateTimeField(auto_now_add=True)), 21 | ], 22 | ), 23 | migrations.CreateModel( 24 | name='Subscriber', 25 | fields=[ 26 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 27 | ('email', models.EmailField(max_length=254, unique=True)), 28 | ('subscriped_at', models.DateTimeField(auto_now_add=True)), 29 | ], 30 | ), 31 | ] 32 | -------------------------------------------------------------------------------- /backend/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/backend/migrations/__init__.py -------------------------------------------------------------------------------- /backend/migrations/__pycache__/0001_initial.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/backend/migrations/__pycache__/0001_initial.cpython-310.pyc -------------------------------------------------------------------------------- /backend/migrations/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/backend/migrations/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /backend/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | class Subscriber(models.Model): 4 | email = models.EmailField(unique=True) 5 | subscriped_at = models.DateTimeField(auto_now_add=True) 6 | 7 | def __str__(self): 8 | return self.email 9 | 10 | class Article(models.Model): 11 | title = models.CharField(max_length=200) 12 | description = models.TextField() 13 | created_at = models.DateTimeField(auto_now_add=True) 14 | 15 | def __str__(self): 16 | return self.title -------------------------------------------------------------------------------- /backend/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /backend/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from .views import * 3 | 4 | app_name = "backend" 5 | 6 | urlpatterns = [ 7 | path("", home, name="home") 8 | ] -------------------------------------------------------------------------------- /backend/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, redirect 2 | from .models import Subscriber, Article 3 | from django.core.mail import send_mail 4 | from django.conf import settings 5 | 6 | 7 | def home(request): 8 | if request.method == "GET": 9 | context = {} 10 | return render(request, "index.html", context) 11 | else: 12 | email = request.POST.get("email") 13 | Subscriber.objects.create(email=email) 14 | sub = "Subscription successful" 15 | msg = f"Hello {email}, Thanks for subscribing us. Now you will get email" 16 | send_mail(sub, msg, settings.EMAIL_HOST_USER, [email], fail_silently=False) 17 | return redirect("/") 18 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python019/async-django-email/2de9a9764245ef294cd0eb396c9f0e60f5650372/db.sqlite3 -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'asyncproject.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.5.2 2 | click==7.1.2 3 | Django==3.2.3 4 | h11==0.12.0 5 | pytz==2022.4 6 | sqlparse==0.4.3 7 | uvicorn==0.13.4 8 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |