Alvaro Bataller
Alvaro Bataller

Reputation: 483

Django Allauth: How to customize confirmation email subject?

I was able to customize the confirmation email HTML template by adding this file into the templates folder:

templates/account/email/email_confirmation_signup_message.html

Now I'm trying to customize the subject of the email by adding the text I want inside this file:

templates/account/email/email_confirmation_signup_subject.txt

But it doesn't seem to do anything, I still get the default subject all the time.

Does anyone know what I'm doing wrong?

Many thanks!

Upvotes: 3

Views: 2921

Answers (5)

Nikos
Nikos

Reputation: 437

  1. For me the default behavior was to have the template in the the project folder and not in the particular apps directory api_project/templates/account/email/email_confirmation_subject.txt!
  2. For anybody that might be here just because [example.com] still appears at the subject even when they customized successfully the templates/account/email/email_confirmation_subject.txt a variable that you need to configure and it's not quit obvious it's ACCOUNT_EMAIL_SUBJECT_PREFIX = '[example.com]'

Upvotes: 3

heber camargo
heber camargo

Reputation: 33

You have to add this two files... first: account/email/email_confirmation_signup_message.html

{% include "account/email/email_confirmation_message.html" %}

second:

account/email/email_confirmation_message.html

The template that you want.

and finally delete the two .txt file: account/email/email_confirmation_signup_message.txt account/email/email_confirmation_message.txt

pd: if you copy the folder template/account from your virtual enviroment you have to delete the files over there as well.

Upvotes: 2

rportron
rportron

Reputation: 1

Maybe the problem comes with your urls.py file You need to indicate here the file you use to customize the subject of your email.

PasswordResetView.as_view(template_name='email_confirmation_signup_message.html', subject_template_name='email_confirmation_signup_subject.txt')

Upvotes: 0

noob
noob

Reputation: 140

Change file name to this:- templates/account/email/email_confirmation_subject.txt and inside write

{% load i18n %}
{% autoescape off %}
{% blocktrans %}Please Confirm Your E-mail Address or do whatever..{% endblocktrans %}
{% endautoescape %}

Upvotes: 1

Ashish Sondagar
Ashish Sondagar

Reputation: 1093

Do in this way...

  • install django-mail-templated

  • base template file code...

{{ TAG_START_SUBJECT }}
{% autoescape off %}
{% block subject %}
{% endblock %}
{% endautoescape %}
{{ TAG_END_SUBJECT }}

  • main template file code...
{% block subject %}
Hello User..
{% endblock %}

Upvotes: 0

Related Questions