ff7da29638
smtp_send: conecta+envia+cierra en un paso via smtplib (TLS/STARTTLS/plain). email_build_html: construye EmailMessagePy frozen dataclass con cuerpo HTML. Solo stdlib Python: smtplib, email.mime. Tests con mock SMTP server threading. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1.8 KiB
1.8 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| email_build_html | function | py | infra | 1.0.0 | pure | email_build_html(from_addr: str, to: list[str], subject: str, body_html: str) -> EmailMessagePy | Construye un EmailMessagePy inmutable con cuerpo HTML. El campo body_text queda vacio. Funcion pura sin efectos secundarios. |
|
false |
|
|
EmailMessagePy inmutable con from_addr, to (como tupla), subject y body_html; body_text vacio | true |
|
python/functions/infra/email_build_html_test.py | python/functions/infra/email_build_html.py |
Ejemplo
from infra.email_build_html import email_build_html
msg = email_build_html(
from_addr="alice@example.com",
to=["bob@example.com", "carol@example.com"],
subject="Reporte mensual",
body_html="<h1>Hola</h1><p>Ver adjunto.</p>",
)
assert msg.body_html == "<h1>Hola</h1><p>Ver adjunto.</p>"
assert msg.body_text == ""
assert isinstance(msg.to, tuple)
Notas
Funcion pura. EmailMessagePy es un dataclass frozen — inmutable por construccion. La lista to se convierte a tupla para evitar mutacion externa. Para usar con smtp_send, pasar los campos del mensaje como argumentos individuales.