Portal Community
Best For General-purpose transactional email. Use SMTP if you already have an email provider or corporate mail server.

SMTP Configuration Parameters

ParameterTypeRequiredExampleNotes
providerstring✅smtpMust be "smtp"
hoststring✅smtp.gmail.comSMTP server hostname
portint✅58725, 465, or 587
sslbool✅falsefalse=STARTTLS, true=SMTPS
fromEmailstring✅[email protected]Sender email address
fromNamestring❌My AppDisplay name for sender

Provider-Specific Configuration

Gmail (Free, Quota 100/day)

{
  "provider": "smtp",
  "host": "smtp.gmail.com",
  "port": 587,
  "ssl": false,
  "fromEmail": "[email protected]",
  "fromName": "Your App"
}

Credentials: Use app-specific password (not your regular Gmail password). Generate at myaccount.google.com/apppasswords

Office 365

{
  "provider": "smtp",
  "host": "smtp.office365.com",
  "port": 587,
  "ssl": false,
  "fromEmail": "[email protected]",
  "fromName": "Your Company"
}

Credentials: Use Office 365 account email and password. May require enabling "Allow less secure apps".

Custom SMTP Server

{
  "provider": "smtp",
  "host": "mail.company.local",
  "port": 25,
  "ssl": false,
  "fromEmail": "[email protected]",
  "fromName": "System Notifications"
}

Credentials: Depends on your server. Often username/password or no auth (internal network).

Port Selection Guide

PortProtocolSSL FieldUse Case
25SMTP (unencrypted)falseInternal networks, no TLS
465SMTPS (implicit SSL)trueOlder servers, immediate encryption
587SMTP + STARTTLSfalseModern servers, upgrade after connect

Credential Creation

Choose a credential name (e.g., "email-primary", "email-smtp", etc.). Configure which name each tenant uses via TenantSettings with Key='EmailCredentialName'.

INSERT INTO AIExt_Credentials (
  Name,
  DisplayMetadata,
  EncryptedData,  -- Your SMTP password (AES-256-GCM encrypted)
  TenantID,
  CredentialTypeID,  -- 1 for PasswordRecord
  Enabled
) VALUES (
  'email-primary',  -- Or any name you configure in TenantSettings
  '{
    "provider": "smtp",
    "host": "smtp.gmail.com",
    "port": 587,
    "ssl": false,
    "fromEmail": "[email protected]",
    "fromName": "Your App"
  }',
  0x...,  -- Encrypted password
  1,      -- TenantID
  1,      -- PasswordRecord type
  1
);

Troubleshooting

"Authentication failed"

"Connection timeout"

"TLS failed"

Testing Your Configuration

// Test with direct call
var result = await _emailService.SendAsync(
    tenantID: 1,
    to: "[email protected]",
    subject: "SMTP Test",
    html: "<p>If you see this, SMTP is working!</p>",
    credentialName: "email-smtp",
    ct: CancellationToken.None
);

if (result.Success)
    Console.WriteLine("✅ SMTP is working!");
else
    Console.WriteLine($"❌ Error: {result.ErrorMessage}");

Next Steps