Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using mail operations by example clean architecture #37

Open
metallist203 opened this issue Aug 23, 2024 · 1 comment
Open

Using mail operations by example clean architecture #37

metallist203 opened this issue Aug 23, 2024 · 1 comment

Comments

@metallist203
Copy link

Hello, i'm developing my project, witch i using aiosmtplib. How i can use this library in clean architecture? Do you have any example?

@cdddg
Copy link
Owner

cdddg commented Oct 10, 2024

Apologies for the delayed reply; I've been busy with work.


The email sending functionality can involve two layers:

Infrastructure Layer: This layer is responsible for interacting with external services like SMTP servers. It handles the technical details of external systems, such as sending emails using aiosmtplib.

Interface Adapters Layer: This layer encapsulates the logic for sending emails, converting application requirements into operations on the infrastructure layer. It defines abstract interfaces.


Based on my experience, I use a folder dedicated to external services:

adapters/mail.py

class MailAdapter:

    def __init__(self, *args, **kwargs):
         ...

    def send_mail(self, *args, **kwargs):
         ...

* If there's a need to configure SMTP settings, I might handle it in infrastructure/mail.py or core/mail.py.

* Naming Issue: For the adapters, I've previously used names like service, adapter, or gateway. Ultimately, our team settled on using adapter based on our preferences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants