Files
egutierrez ef3ae2aae9 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>
2026-04-13 02:01:13 +02:00

1.5 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
smtp_connect function go infra 1.0.0 impure func SMTPConnect(cfg SMTPConfig) (*smtp.Client, error) Establece una conexion SMTP autenticada. TLSMode 'tls' usa TLS directo (port 465), 'starttls' hace upgrade STARTTLS (port 587), '' sin cifrado (port 25). Retorna un *smtp.Client listo para usar con SMTPSend.
email
smtp
connection
tls
starttls
auth
SMTPConfig_go_infra
false error_go_core
crypto/tls
fmt
net
net/smtp
name desc
cfg configuracion SMTP: host, port, usuario, password y modo TLS
*smtp.Client autenticado y listo para enviar mensajes; el caller debe llamar client.Quit() al terminar true
conecta sin cifrado a servidor mock
error si el servidor no existe
functions/infra/smtp_connect_test.go functions/infra/smtp_connect.go

Ejemplo

cfg := SMTPConfig{Host: "smtp.gmail.com", Port: 587, Username: "u@gmail.com", Password: "app-pw", TLSMode: "starttls"}
client, err := SMTPConnect(cfg)
if err != nil {
    log.Fatal(err)
}
defer client.Quit()
// pasar client a SMTPSend(...)

Notas

Funcion impura — abre conexion TCP real. El caller es responsable de cerrar el cliente con client.Quit(). Para test unitario usar un listener TCP local como mock. SMTPSend acepta el *smtp.Client retornado por esta funcion.