-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ add email client with local email server
- Loading branch information
1 parent
187cd5b
commit e9bc7e7
Showing
5 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import logging | ||
import time | ||
from datetime import datetime | ||
from email.message import EmailMessage | ||
|
||
from src.config import SMTPClient | ||
|
||
from .config import S3, S3_BUCKET_NAME | ||
|
||
|
@@ -21,3 +24,12 @@ def upload_image(content: bytes, image_key: str): | |
"bg_image_url": image_key, | ||
} | ||
logging.info("Upload successful", extra=extras_logging) | ||
|
||
|
||
def send_mail(subject: str, to: str, message: str): | ||
msg = EmailMessage() | ||
msg["Subject"] = subject | ||
msg["From"] = "[email protected]" | ||
msg["To"] = to | ||
msg.set_content(message) | ||
SMTPClient.send_message(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from fastapi.testclient import TestClient | ||
from src.main import app | ||
from src.utils import send_mail | ||
|
||
client = TestClient(app) | ||
|
||
|
||
class TestEmail: | ||
def test_email(self): | ||
send_mail( | ||
subject="Demande d'avis à un expert", | ||
to="[email protected]", | ||
message="Message de test", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters