Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ The app is packed with default HTML templates to handle the web pages but if you
```
HTML_MESSAGE_TEMPLATE = "path/to/html_template.html"

EMAIL_VERIFICATION_SUBJECT_TEMPLATE = "path/to/subject.txt"

VERIFICATION_SUCCESS_TEMPLATE = "path/to/success.html"

VERIFICATION_FAILED_TEMPLATE = "path/to/failed.html"
Expand All @@ -299,11 +301,6 @@ LINK_EXPIRED_TEMPLATE = 'path/to/expired.html'

NEW_EMAIL_SENT_TEMPLATE = 'path/to/new_email_sent.html'
```
```
SUBJECT = 'subject of email'

# default subject is: Email Verification Mail
```
</p>

## Inside Templates : <hr>
Expand Down
6 changes: 3 additions & 3 deletions verify_email/app_configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def __init__(self):
False
),

'subject': (
"SUBJECT",
"Email Verification Mail"
'email_verification_subject_template': (
"EMAIL_VERIFICATION_SUBJECT_TEMPLATE",
"verify_email/email_verification_subject.txt"
),

'email_field_name': (
Expand Down
16 changes: 12 additions & 4 deletions verify_email/email_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ def __init__(self):
self.token_manager = TokenManager()

# Private :
def __send_email(self, msg, useremail):
subject = self.settings.get('subject')
def __send_email(self, subject, msg, useremail):
send_mail(
subject, strip_tags(msg),
from_email=self.settings.get('from_alias'),
recipient_list=[useremail], html_message=msg
)

def __get_subject(self, request):
subject_template_name = self.settings.get('email_verification_subject_template')
subject = render_to_string(subject_template_name, dict(), request=request)
# Email subject *must not* contain newlines
return "".join(subject.splitlines())

# Public :
def send_verification_link(self, request, inactive_user=None, form=None):

Expand All @@ -52,8 +57,9 @@ def send_verification_link(self, request, inactive_user=None, form=None):
{"link": verification_url, "inactive_user": inactive_user},
request=request
)
subject = self.__get_subject(request)

self.__send_email(msg, useremail)
self.__send_email(subject, msg, useremail)
return inactive_user
except Exception:
inactive_user.delete()
Expand Down Expand Up @@ -88,7 +94,9 @@ def resend_verification_link(self, request, email, **kwargs):
self.settings.get('html_message_template', raise_exception=True),
{"link": link}, request=request
)
self.__send_email(msg, email)
subject = self.__get_subject(request)

self.__send_email(subject, msg, email)
return True


Expand Down
24 changes: 24 additions & 0 deletions verify_email/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Django-Verify-Email
# Copyright (C) 2023 Django-Verify-Email contributors
# This file is distributed under the same license as the PACKAGE package.
# Sebastian Haas, 2023
# SECOND AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-06 14:25+0100\n"
"PO-Revision-Date: 2023-11-06 14:27+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.4.1\n"

#: templates/verify_email/email_verification_subject.txt:3
msgid "Confirm Your Email Address"
msgstr "E-Mail-Adresse bestätigen"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% load i18n %}
{% autoescape off %}
{% blocktranslate %}Confirm Your Email Address{% endblocktranslate %}
{% endautoescape %}