MCPcopy Create free account
hub / github.com/simstudioai/sim / createSmtpProvider

Function createSmtpProvider

apps/sim/lib/messaging/email/providers/smtp.ts:9–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7const logger = createLogger('SmtpMailProvider')
8
9export function createSmtpProvider(): MailProvider | null {
10 const host = env.SMTP_HOST
11 if (!host) return null
12
13 const port = envNumber(env.SMTP_PORT, 0, { min: 1 })
14 if (port === 0) {
15 logger.warn(
16 'SMTP_HOST is set but SMTP_PORT is missing or invalid; skipping SMTP provider. Set SMTP_PORT to 465 (TLS), 587 (STARTTLS), or 25 (plain).'
17 )
18 return null
19 }
20
21 const user = env.SMTP_USER
22 const pass = env.SMTP_PASS
23 if ((user && !pass) || (!user && pass)) {
24 logger.warn(
25 'SMTP_USER and SMTP_PASS must both be set for authenticated relays; proceeding without auth.'
26 )
27 }
28
29 const transporter = nodemailer.createTransport({
30 host,
31 port,
32 secure: envBoolean(env.SMTP_SECURE) ?? port === 465,
33 auth: user && pass ? { user, pass } : undefined,
34 })
35
36 return {
37 name: 'smtp',
38 send: (data) => sendViaNodemailer(transporter, data, 'smtp'),
39 }
40}

Callers

nothing calls this directly

Calls 4

envNumberFunction · 0.90
envBooleanFunction · 0.90
sendViaNodemailerFunction · 0.90
warnMethod · 0.65

Tested by

no test coverage detected