Skip to content

Commit f1a6f3f

Browse files
author
Adrian Berger
committed
feat: add name as part of sender
1 parent 769c67c commit f1a6f3f

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

django_mailomat/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from django_mailomat.backend import MailomatEmailBackend
22

3-
__version__ = '0.3.0'
3+
__version__ = '0.4.0'
44
__all__ = ['MailomatEmailBackend']

django_mailomat/backend.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ def _sanitize_email(self, email: str) -> str:
2727
return email.split('<')[1].split('>')[0]
2828
return email
2929

30-
def _format_email(self, email: str, name: Optional[str] = None) -> str:
30+
def _format_email(self, email: str, name: Optional[str] = None) -> dict:
3131
"""
3232
Format email address with optional display name.
33+
Returns a dictionary with email and name fields.
34+
If no name is provided, uses the email address as the name.
3335
"""
34-
if name:
35-
return formataddr((name, self._sanitize_email(email)))
36-
return self._sanitize_email(email)
36+
sanitized_email = self._sanitize_email(email)
37+
return {
38+
'email': sanitized_email,
39+
'name': name if name else sanitized_email
40+
}
3741

3842
def _send(self, email_message: Union[EmailMessage, EmailMultiAlternatives]) -> bool:
3943
"""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "django-mailomat"
7-
version = "0.3.0"
7+
version = "0.4.0"
88
description = "Django email backend for Mailomat API"
99
readme = "README.md"
1010
requires-python = ">=3.9"

0 commit comments

Comments
 (0)