mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: passage des mail au format HTML
This commit is contained in:
@ -230,21 +230,9 @@ EMAIL_HOST_PASSWORD=jsonObject['password']
|
|||||||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||||
EMAIL_USE_TLS = True
|
EMAIL_USE_TLS = True
|
||||||
EMAIL_USE_SSL = False
|
EMAIL_USE_SSL = False
|
||||||
EMAIL_INSCRIPTION_SUBJECT = '[N3WT-SCHOOL] Dossier Inscription'
|
|
||||||
EMAIL_INSCRIPTION_CORPUS = """Bonjour,
|
|
||||||
|
|
||||||
Afin de procéder à l'inscription de votre petit bout, vous trouverez ci-joint le lien vers la page d'authentification : """ + BASE_URL + """/users/login
|
|
||||||
|
|
||||||
S'il s'agit de votre première connexion, veuillez procéder à l'activation de votre compte : """ + BASE_URL + """/users/subscribe
|
|
||||||
identifiant = %s
|
|
||||||
|
|
||||||
Cordialement,
|
|
||||||
"""
|
|
||||||
|
|
||||||
EMAIL_RELANCE_SUBJECT = '[N3WT-SCHOOL] Relance - Dossier Inscription'
|
|
||||||
EMAIL_RELANCE_CORPUS = 'Bonjour,\nN\'ayant pas eu de retour de votre part, nous vous renvoyons le lien vers le formulaire d\'inscription : ' + BASE_URL + '/users/login\nCordialement'
|
|
||||||
EMAIL_REINIT_SUBJECT = 'Réinitialisation du mot de passe'
|
|
||||||
EMAIL_REINIT_CORPUS = 'Bonjour,\nVous trouverez ci-joint le lien pour réinitialiser votre mot de passe : ' + BASE_URL + '/users/password/reset?uuid=%s\nCordialement'
|
|
||||||
|
|
||||||
DOCUMENT_DIR = 'documents'
|
DOCUMENT_DIR = 'documents'
|
||||||
|
|
||||||
|
|||||||
@ -1,38 +1,59 @@
|
|||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail, EmailMultiAlternatives, EmailMessage
|
||||||
|
from django.template.loader import render_to_string
|
||||||
|
from django.utils.html import strip_tags
|
||||||
import re
|
import re
|
||||||
from N3wtSchool import settings
|
from N3wtSchool import settings
|
||||||
|
|
||||||
def envoieReinitMotDePasse(recipients, code):
|
def envoieReinitMotDePasse(recipients, code):
|
||||||
send_mail(
|
errorMessage = ''
|
||||||
settings.EMAIL_REINIT_SUBJECT,
|
try:
|
||||||
settings.EMAIL_REINIT_CORPUS%(str(code)),
|
EMAIL_REINIT_SUBJECT = 'Réinitialisation du mot de passe'
|
||||||
settings.EMAIL_HOST_USER,
|
context = {
|
||||||
[recipients],
|
'BASE_URL': settings.BASE_URL,
|
||||||
fail_silently=False,
|
'code': str(code)
|
||||||
)
|
}
|
||||||
|
subject = EMAIL_REINIT_SUBJECT
|
||||||
|
html_message = render_to_string('emails/resetPassword.html', context)
|
||||||
|
plain_message = strip_tags(html_message)
|
||||||
|
from_email = settings.EMAIL_HOST_USER
|
||||||
|
send_mail(subject, plain_message, from_email, [recipients], html_message=html_message)
|
||||||
|
except Exception as e:
|
||||||
|
errorMessage = str(e)
|
||||||
|
|
||||||
|
return errorMessage
|
||||||
|
|
||||||
|
|
||||||
def sendRegisterForm(recipients):
|
def sendRegisterForm(recipients):
|
||||||
errorMessage = ''
|
errorMessage = ''
|
||||||
try:
|
try:
|
||||||
print(f'{settings.EMAIL_HOST_USER}')
|
print(f'{settings.EMAIL_HOST_USER}')
|
||||||
send_mail(
|
# Préparation du contexte pour le template
|
||||||
settings.EMAIL_INSCRIPTION_SUBJECT,
|
EMAIL_INSCRIPTION_SUBJECT = '[N3WT-SCHOOL] Dossier Inscription'
|
||||||
settings.EMAIL_INSCRIPTION_CORPUS%[recipients],
|
context = {
|
||||||
settings.EMAIL_HOST_USER,
|
'BASE_URL': settings.BASE_URL,
|
||||||
[recipients],
|
'email': recipients
|
||||||
fail_silently=False,
|
}
|
||||||
)
|
|
||||||
|
subject = EMAIL_INSCRIPTION_SUBJECT
|
||||||
|
html_message = render_to_string('emails/inscription.html', context)
|
||||||
|
plain_message = strip_tags(html_message)
|
||||||
|
from_email = settings.EMAIL_HOST_USER
|
||||||
|
|
||||||
|
send_mail(subject, plain_message, from_email, [recipients], html_message=html_message)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errorMessage = str(e)
|
errorMessage = str(e)
|
||||||
|
|
||||||
return errorMessage
|
return errorMessage
|
||||||
|
|
||||||
def envoieRelanceDossierInscription(recipients, code):
|
def envoieRelanceDossierInscription(recipients, code):
|
||||||
|
EMAIL_RELANCE_SUBJECT = '[N3WT-SCHOOL] Relance - Dossier Inscription'
|
||||||
|
EMAIL_RELANCE_CORPUS = 'Bonjour,\nN\'ayant pas eu de retour de votre part, nous vous renvoyons le lien vers le formulaire d\'inscription : ' + BASE_URL + '/users/login\nCordialement'
|
||||||
errorMessage = ''
|
errorMessage = ''
|
||||||
try:
|
try:
|
||||||
send_mail(
|
send_mail(
|
||||||
settings.EMAIL_RELANCE_SUBJECT,
|
EMAIL_RELANCE_SUBJECT,
|
||||||
settings.EMAIL_RELANCE_CORPUS%str(code),
|
EMAIL_RELANCE_CORPUS%str(code),
|
||||||
settings.EMAIL_HOST_USER,
|
settings.EMAIL_HOST_USER,
|
||||||
[recipients],
|
[recipients],
|
||||||
fail_silently=False,
|
fail_silently=False,
|
||||||
@ -42,16 +63,6 @@ def envoieRelanceDossierInscription(recipients, code):
|
|||||||
|
|
||||||
return errorMessage
|
return errorMessage
|
||||||
|
|
||||||
|
|
||||||
def envoieSEPA(recipients, ref):
|
|
||||||
send_mail(
|
|
||||||
settings.EMAIL_SEPA_SUBJECT%str(ref),
|
|
||||||
settings.EMAIL_SEPA_CORPUS,
|
|
||||||
settings.EMAIL_HOST_USER,
|
|
||||||
[recipients],
|
|
||||||
fail_silently=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
def isValid(message, fiche_inscription):
|
def isValid(message, fiche_inscription):
|
||||||
# Est-ce que la référence du dossier est VALIDE
|
# Est-ce que la référence du dossier est VALIDE
|
||||||
subject = message.subject
|
subject = message.subject
|
||||||
|
|||||||
52
Back-End/Subscriptions/templates/emails/inscription.html
Normal file
52
Back-End/Subscriptions/templates/emails/inscription.html
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Confirmation d'inscription</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
padding: 10px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.content {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 30px;
|
||||||
|
color: #777;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<h1>Confirmation d'inscription</h1>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<p>Bonjour,</p>
|
||||||
|
<p>Nous vous confirmons la réception de votre demande d'inscription, vous trouverez ci-joint le lien vers la page d'authentification : <a href="{{BASE_URL}}/users/login">{{BASE_URL}}/users/login</a></p>
|
||||||
|
<p>S'il s'agit de votre première connexion, veuillez procéder à l'activation de votre compte à cette url : <a href="{{BASE_URL}}/users/subscribe">{{BASE_URL}}/users/subscribe</a></p>
|
||||||
|
<p>votre identifiant est : {{ email }}</p>
|
||||||
|
<p>Merci de compléter votre dossier d'inscription en suivant les instructions fournies.</p>
|
||||||
|
<p>Cordialement,</p>
|
||||||
|
<p>L'équipe N3wt School</p>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<p>Ce message est généré automatiquement, merci de ne pas y répondre.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
49
Back-End/Subscriptions/templates/emails/resetPassword.html
Normal file
49
Back-End/Subscriptions/templates/emails/resetPassword.html
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Confirmation d'inscription</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
padding: 10px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.content {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 30px;
|
||||||
|
color: #777;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<h1>Confirmation d'inscription</h1>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<p>Bonjour,</p>
|
||||||
|
<p>Vous trouverez ci-joint le lien pour réinitialiser votre mot de passe : <a href="{{BASE_URL}}/users/password/reset?uuid={{code}}">{{BASE_URL}}/users/password/reset?uuid={{code}}</a></p>
|
||||||
|
<p>Cordialement,</p>
|
||||||
|
<p>L'équipe N3wt School</p>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<p>Ce message est généré automatiquement, merci de ne pas y répondre.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user