Skip to main content

SMTP & IMAP Configuration Guide

This guide covers setting up SMTP (Simple Mail Transfer Protocol) for sending emails and IMAP (Internet Message Access Protocol) for receiving emails through your own mail servers.


Overview

EDITH supports two types of email configurations:

ProtocolPurposeUse Case
SMTPSending emailsSend through your own mail server (Gmail, Outlook, custom SMTP)
IMAPReceiving emailsMonitor an inbox and process incoming emails via webhooks

Both support two connection types:

  • Basic: Username and password authentication
  • OAuth: Token-based authentication (for Gmail, Outlook, etc.)

SMTP Configuration

Create SMTP Configuration

Endpoint

POST /v1/smtpbasic/verify

Purpose

Creates a new SMTP configuration and verifies the connection by testing authentication with the provided credentials.

Request Body

FieldTypeRequiredDescription
namestring✅ YesA descriptive name for this configuration (e.g., "Gmail SMTP", "Corporate Outlook")
emailstring✅ YesThe email address associated with this SMTP account. Must be a valid email format.
connection_typestring✅ YesAuthentication method. Values: "basic" (username/password) or "oauth"
config_typestring✅ YesMust be "smtp"
configobject✅ YesSMTP server configuration details

Config Object

FieldTypeRequiredDescription
hoststring✅ YesSMTP server hostname (e.g., smtp.gmail.com, smtp.office365.com)
portinteger✅ YesSMTP server port. Common ports: 587 (TLS), 465 (SSL), 25 (unencrypted)
securestring✅ YesSecurity protocol. Options: "Auto", "TlsWhenAvailable", "Tls", "SSL", "None"
usernamestring✅ YesSMTP authentication username (often the email address)
passwordstring✅ YesSMTP authentication password or app-specific password

Security Options Explained

OptionDescriptionRecommended Port
AutoAutomatically detect and use the best available securityAny
TlsWhenAvailableUse TLS if server supports it, otherwise unencrypted587
TlsRequire TLS (STARTTLS) - connection starts unencrypted, upgrades to TLS587
SSLUse implicit SSL/TLS - connection is encrypted from start465
NoneNo encryption (not recommended)25

Example Request - Gmail SMTP

curl -X POST https://api.edith.example.com/v1/smtpbasic/verify \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Gmail SMTP",
"email": "yourname@gmail.com",
"connection_type": "basic",
"config_type": "smtp",
"config": {
"host": "smtp.gmail.com",
"port": 587,
"secure": "Tls",
"username": "yourname@gmail.com",
"password": "your-app-specific-password"
}
}'

Example Request - Microsoft 365

curl -X POST https://api.edith.example.com/v1/smtpbasic/verify \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Office 365 SMTP",
"email": "yourname@yourcompany.com",
"connection_type": "basic",
"config_type": "smtp",
"config": {
"host": "smtp.office365.com",
"port": 587,
"secure": "Tls",
"username": "yourname@yourcompany.com",
"password": "your-password"
}
}'

Response

{
"success": true,
"mailer_id": "basic_smtp_01JC3BBW8S9YGX2VNKG5MD7BTA"
}
FieldDescription
successBoolean indicating the SMTP configuration was verified and created
mailer_idUnique identifier for this SMTP configuration. Use this when sending emails.

Update SMTP Configuration

Endpoint

PUT /v1/smtpbasic/update

Purpose

Updates an existing SMTP configuration and re-verifies the connection.

Request Body

All fields from create, plus:

FieldTypeRequiredDescription
mailer_idstring✅ YesThe ID of the SMTP configuration to update

Example Request

curl -X PUT https://api.edith.example.com/v1/smtpbasic/update \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"mailer_id": "basic_smtp_01JC3BBW8S9YGX2VNKG5MD7BTA",
"name": "Gmail SMTP Updated",
"email": "yourname@gmail.com",
"connection_type": "basic",
"config_type": "smtp",
"config": {
"host": "smtp.gmail.com",
"port": 587,
"secure": "Tls",
"username": "yourname@gmail.com",
"password": "new-app-specific-password"
}
}'

Get SMTP Configuration

Endpoint

GET /v1/smtpbasic/get/{mailer_id}

Purpose

Retrieves the details of an existing SMTP configuration. Password is not returned for security.

Path Parameters

ParameterTypeRequiredDescription
mailer_idstring✅ YesThe SMTP configuration ID

Example Request

curl -X GET https://api.edith.example.com/v1/smtpbasic/get/basic_smtp_01JC3BBW8S9YGX2VNKG5MD7BTA \
-H "Authorization: Bearer YOUR_TOKEN"

Response

{
"success": true,
"name": "Gmail SMTP",
"email": "yourname@gmail.com",
"connection_type": "basic",
"config_type": "smtp",
"active": true,
"config": {
"host": "smtp.gmail.com",
"port": 587,
"secure": "Tls",
"username": "yourname@gmail.com"
}
}

Note: The password is never returned in API responses for security reasons.


Delete SMTP Configuration

Endpoint

DELETE /v1/smtpbasic/delete/{mailer_id}

Purpose

Permanently deletes an SMTP configuration.

Example Request

curl -X DELETE https://api.edith.example.com/v1/smtpbasic/delete/basic_smtp_01JC3BBW8S9YGX2VNKG5MD7BTA \
-H "Authorization: Bearer YOUR_TOKEN"

Response

{
"success": true
}

IMAP Configuration

Create IMAP Configuration

Endpoint

POST /v1/imapbasic/verify

Purpose

Creates a new IMAP configuration for monitoring an email inbox. When new emails arrive, they're forwarded to your webhook endpoint.

Request Body

FieldTypeRequiredDescription
namestring✅ YesDescriptive name for this IMAP configuration
emailstring✅ YesThe email address of the inbox to monitor
connection_typestring✅ YesValues: "basic" or "oauth"
config_typestring✅ YesMust be "imap"
configobject✅ YesIMAP server configuration
webhookobject✅ YesWebhook configuration for incoming emails
strict_repliesbooleanNoWhen true, only process emails that are replies to sent emails. Default: false
include_spambooleanNoInclude emails from spam folder. Default: false
include_trashbooleanNoInclude emails from trash folder. Default: false
include_sentbooleanNoInclude emails from sent folder. Default: false

Config Object (IMAP)

FieldTypeRequiredDescription
hoststring✅ YesIMAP server hostname (e.g., imap.gmail.com)
portinteger✅ YesIMAP server port. Common: 993 (SSL), 143 (TLS)
securestring✅ YesSecurity protocol: "SSL" (recommended), "TLS", "None"
usernamestring✅ YesIMAP authentication username
passwordstring✅ YesIMAP authentication password or app-specific password

Webhook Object

FieldTypeRequiredDescription
webhook_urlstring✅ YesURL to receive incoming email notifications
eventstring✅ YesMust be "BASIC_IMAP"
methodstring✅ YesHTTP method: "GET", "POST", "PUT", "DELETE", "PATCH"
headersobjectNoCustom headers to include in webhook requests

Example Request

curl -X POST https://api.edith.example.com/v1/imapbasic/verify \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Support Inbox Monitor",
"email": "support@yourcompany.com",
"connection_type": "basic",
"config_type": "imap",
"config": {
"host": "imap.gmail.com",
"port": 993,
"secure": "SSL",
"username": "support@yourcompany.com",
"password": "your-app-specific-password"
},
"webhook": {
"webhook_url": "https://api.yourcompany.com/webhooks/incoming-email",
"event": "BASIC_IMAP",
"method": "POST",
"headers": {
"X-Webhook-Secret": "your-secret-key"
}
},
"strict_replies": false,
"include_spam": false,
"include_trash": false,
"include_sent": false
}'

Response

{
"success": true,
"mailer_id": "basic_imap_01JC3BBW8S9YGX2VNKG5MD7BTA"
}

Folder Monitoring Options

OptionDefaultDescription
strict_repliesfalseOnly forward emails that are replies to previously sent emails. Useful for tracking conversation threads.
include_spamfalseMonitor the spam/junk folder. Enable to catch misclassified emails.
include_trashfalseMonitor the trash/deleted folder. Rarely needed.
include_sentfalseMonitor the sent folder. Useful for auditing or syncing sent emails.

Update IMAP Configuration

Endpoint

PUT /v1/imapbasic/update

Purpose

Updates an existing IMAP configuration and re-verifies the connection.

Request Body

All fields from create, plus:

FieldTypeRequiredDescription
mailer_idstring✅ YesThe ID of the IMAP configuration to update

Example Request

curl -X PUT https://api.edith.example.com/v1/imapbasic/update \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"mailer_id": "basic_imap_01JC3BBW8S9YGX2VNKG5MD7BTA",
"name": "Support Inbox - Updated",
"email": "support@yourcompany.com",
"connection_type": "basic",
"config_type": "imap",
"config": {
"host": "imap.gmail.com",
"port": 993,
"secure": "SSL",
"username": "support@yourcompany.com",
"password": "new-app-password"
},
"webhook": {
"webhook_url": "https://api.yourcompany.com/webhooks/v2/incoming-email",
"event": "BASIC_IMAP",
"method": "POST"
},
"strict_replies": true
}'

Get IMAP Configuration

Endpoint

GET /v1/imapbasic/get/{mailer_id}

Example Request

curl -X GET https://api.edith.example.com/v1/imapbasic/get/basic_imap_01JC3BBW8S9YGX2VNKG5MD7BTA \
-H "Authorization: Bearer YOUR_TOKEN"

Response

{
"success": true,
"name": "Support Inbox Monitor",
"email": "support@yourcompany.com",
"connection_type": "basic",
"config_type": "imap",
"active": true,
"strict_replies": false,
"include_spam": false,
"include_trash": false,
"include_sent": false,
"config": {
"host": "imap.gmail.com",
"port": 993,
"secure": "SSL",
"username": "support@yourcompany.com"
},
"webhook": {
"webhook_url": "https://api.yourcompany.com/webhooks/incoming-email",
"event": "BASIC_IMAP",
"method": "POST"
}
}

Delete IMAP Configuration

Endpoint

DELETE /v1/imapbasic/delete/{mailer_id}

Example Request

curl -X DELETE https://api.edith.example.com/v1/imapbasic/delete/basic_imap_01JC3BBW8S9YGX2VNKG5MD7BTA \
-H "Authorization: Bearer YOUR_TOKEN"

OAuth Configuration

For Gmail, Outlook, and other OAuth-enabled providers, use the OAuth endpoints for more secure token-based authentication.

Initiate OAuth Login

Endpoint

POST /v1/oauth/login

Purpose

Starts the OAuth authentication flow. Returns a URL to redirect users for authorization.

Request Body

FieldTypeRequiredDescription
app_idstring✅ YesYour registered OAuth application ID
typestringNoConfiguration type: "smtp", "imap", or both
redirect_uristringNoURL to redirect after OAuth completion
statestringNoCSRF token to verify the callback
exchange_tokenbooleanNoSet true if you have a token to exchange
tokenobjectNoToken object for exchange flow
webhookobjectNoWebhook configuration (for IMAP)
mailer_idstringNoExisting mailer_id to update
strict_repliesbooleanNoOnly process reply emails
include_spambooleanNoInclude spam folder
include_trashbooleanNoInclude trash folder
include_sentbooleanNoInclude sent folder

Example Request - New OAuth Flow

curl -X POST https://api.edith.example.com/v1/oauth/login \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"app_id": "your-oauth-app-id",
"type": "smtp",
"redirect_uri": "https://yourapp.com/oauth/callback",
"state": "random-csrf-token"
}'

Response

{
"success": true,
"url": "https://accounts.google.com/o/oauth2/v2/auth?client_id=...&redirect_uri=..."
}

Redirect the user to the returned URL to complete OAuth authorization.


Activate/Deactivate OAuth Configuration

Endpoint

PUT /v1/oauth/active

Purpose

Enable or disable an OAuth email configuration without deleting it.

Request Body

FieldTypeRequiredDescription
mailer_idstring✅ YesThe OAuth configuration ID
activebooleanNoSet true to activate, false to deactivate

Example Request

curl -X PUT https://api.edith.example.com/v1/oauth/active \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"mailer_id": "oauth_01JC3BBW8S9YGX2VNKG5MD7BTA",
"active": false
}'

Common SMTP/IMAP Settings

Gmail

SettingSMTPIMAP
Hostsmtp.gmail.comimap.gmail.com
Port587 (TLS)993 (SSL)
SecurityTlsSSL
UsernameFull email addressFull email address
PasswordApp-specific passwordApp-specific password

Note: Gmail requires an app-specific password. Enable 2FA and generate one at Google Account Security.

Microsoft 365 / Outlook

SettingSMTPIMAP
Hostsmtp.office365.comoutlook.office365.com
Port587993
SecurityTlsSSL
UsernameFull email addressFull email address
PasswordAccount passwordAccount password

Yahoo Mail

SettingSMTPIMAP
Hostsmtp.mail.yahoo.comimap.mail.yahoo.com
Port587993
SecurityTlsSSL

Troubleshooting

SMTP Errors

ErrorCauseSolution
Authentication failedIncorrect credentialsVerify username/password, use app-specific password
Connection refusedWrong host or portCheck server settings
Connection timeoutFirewall blockingEnsure port is open
TLS handshake failedSSL/TLS mismatchTry different security option

IMAP Errors

ErrorCauseSolution
Mailbox not foundIncorrect folder accessVerify email has inbox access
Authentication failedInvalid credentialsUse app-specific password
Connection closedServer timeoutCheck server stability

Best Practices

  1. Use App-Specific Passwords

    • Never use your main account password
    • Generate dedicated passwords for EDITH
  2. Prefer OAuth When Available

    • More secure than basic auth
    • Automatic token refresh
    • Better audit trail
  3. Use Secure Connections

    • Always use SSL or TLS
    • Avoid None security option
  4. Monitor Webhook Health

    • Ensure webhook endpoints are reliable
    • Implement retry logic
    • Log incoming requests
  5. Test Before Production

    • Verify configurations with test emails
    • Monitor for authentication failures