feat: tipos y funciones email SMTP en Go (infra)

Tipos: EmailAttachment, EmailMessage, SMTPConfig.
Puras: email_build_html, email_build_text, email_with_attachment, email_template_render.
Impuras: smtp_connect (TLS/STARTTLS/plain), smtp_send (MIME multipart con adjuntos).
Solo stdlib: net/smtp, crypto/tls, text/template, mime/multipart.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-13 02:01:13 +02:00
parent eca52b1329
commit ef3ae2aae9
16 changed files with 746 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
package infra
import (
"bytes"
"fmt"
"text/template"
)
// EmailTemplateRender executes a Go text/template with the given data map
// and returns the rendered string.
// tmplStr is the template source (Go text/template syntax).
// data is a map of string keys to any values available inside the template.
// Returns an error if the template fails to parse or execute.
func EmailTemplateRender(tmplStr string, data map[string]any) (string, error) {
tmpl, err := template.New("email").Parse(tmplStr)
if err != nil {
return "", fmt.Errorf("email_template_render: parse: %w", err)
}
var buf bytes.Buffer
if err := tmpl.Execute(&buf, data); err != nil {
return "", fmt.Errorf("email_template_render: execute: %w", err)
}
return buf.String(), nil
}