MCPcopy Create free account
hub / github.com/dbunt1tled/python-fast-api / send_email

Method send_email

src/core/service/email/email_service.py:28–50  ·  view source on GitHub ↗
(self, message: EMessage)

Source from the content-addressed store, hash-verified

26 self.app_password = app_password
27
28 def send_email(self, message: EMessage) -> None:
29 msg = MIMEMultipart()
30 msg["From"] = self.from_email
31 msg["To"] = message.to if isinstance(message.to, str) else ", ".join(message.to)
32 msg["Subject"] = message.subject
33 if message.cc:
34 msg["Cc"] = ", ".join(message.cc)
35
36 if message.bcc:
37 msg["Bcc"] = ", ".join(message.bcc)
38
39 msg.attach(MIMEText(message.body, message.body_type))
40
41 if message.attachments:
42 for file_path in message.attachments:
43 file = Path(file_path)
44 if not file.exists():
45 raise NotFoundException(
46 error_no=ErrorNo.EMAIL_ATTACHMENT_NOT_FOUND, message=f"File not found: {file_path}"
47 )
48 msg.attach(EmailService._attach_file(file))
49
50 self._send_message(msg, message.to)
51
52 @staticmethod
53 def _attach_file(file_path: Path) -> MIMEBase:

Callers 1

send_confirm_emailMethod · 0.45

Calls 4

_send_messageMethod · 0.95
NotFoundExceptionClass · 0.90
existsMethod · 0.80
_attach_fileMethod · 0.80

Tested by

no test coverage detected