Ana içeriğe geç
Bu sayfa henüz Türkçeye çevrilmedi; İngilizce sürümü gösteriliyor.
Versiyon: 1.6

Email Worker

The Email Worker is a production-ready worker that sends emails via SMTP. It supports multiple SMTP configurations, HTML and plain text emails, attachments, CC/BCC, and all standard email features.

Features​

  • Multiple SMTP configurations (Default, Marketing, Transactional, etc.)
  • HTML and plain text email body
  • File attachments (regular and inline for HTML)
  • CC and BCC recipients
  • Custom email headers
  • Email priority levels (High, Normal, Low)
  • Read and delivery receipts
  • Reply-To address
  • Automatic retry for transient errors
  • Permanent failure detection (no retry for invalid recipients)

Use Cases​

ScenarioExample
Transactional EmailsOrder confirmations, password resets
NotificationsAlert emails, status updates
Marketing CampaignsScheduled newsletter sends
ReportsDaily/weekly report delivery with attachments
System AlertsError notifications, monitoring alerts
Welcome EmailsNew user onboarding sequences

Security Model​

Like the SQL Worker, SMTP credentials are stored securely in the worker configuration, not in job data.

Worker (appsettings.json)

EmailConfig
└─ SmtpConfigs
└─ Default
├─ Host: smtp.gmail.com
├─ Username: ********
└─ Password: ********

(secrets stay here)

Only the configuration name (alias) is referenced in job data:

{
"configName": "Default",
"to": ["[email protected]"],
"subject": "Welcome!",
"body": "<h1>Hello!</h1>"
}

This design ensures that sensitive credentials never leave the worker environment.

Worker Configuration​

Configure SMTP servers in the worker's appsettings.json:

{
"EmailConfig": {
"DefaultConfigName": "Default",
"SmtpConfigs": {
"Default": {
"Host": "smtp.gmail.com",
"Port": 587,
"Username": "[email protected]",
"Password": "your-app-password",
"UseSsl": true,
"DefaultFromEmail": "[email protected]",
"DefaultFromName": "Your Company",
"TimeoutSeconds": 30,
"IgnoreCertificateErrors": false
},
"Marketing": {
"Host": "smtp.sendgrid.net",
"Port": 587,
"Username": "apikey",
"Password": "your-sendgrid-api-key",
"UseSsl": true,
"DefaultFromEmail": "[email protected]",
"DefaultFromName": "Your Company Marketing",
"TimeoutSeconds": 30
},
"Transactional": {
"Host": "smtp.mailgun.org",
"Port": 587,
"Username": "[email protected]",
"Password": "your-mailgun-password",
"UseSsl": true,
"DefaultFromEmail": "[email protected]",
"DefaultFromName": "Your Company"
}
}
}
}

SMTP Configuration Properties​

PropertyTypeRequiredDefaultDescription
Hoststring✓-SMTP server hostname
Portnumber-587SMTP port (25, 465, or 587)
Usernamestring--SMTP authentication username
Passwordstring--SMTP authentication password
UseSslboolean-trueEnable SSL/TLS encryption
DefaultFromEmailstring✓-Default sender email address
DefaultFromNamestring--Default sender display name
TimeoutSecondsnumber-30Connection timeout
IgnoreCertificateErrorsboolean-falseSkip SSL certificate validation

Job Data Schema​

When creating an email job, provide the email details through Job Data JSON:

{
"configName": "Default",
"to": ["[email protected]"],
"cc": ["[email protected]"],
"bcc": ["[email protected]"],
"subject": "Monthly Report - January 2024",
"body": "<h1>Monthly Report</h1><p>Please find attached...</p>",
"isHtml": true,
"fromEmail": "[email protected]",
"fromName": "Reports System",
"replyTo": "[email protected]",
"priority": "High",
"attachments": [
{
"fileName": "report.pdf",
"contentBase64": "JVBERi0xLjQK...",
"contentType": "application/pdf"
}
],
"requestReadReceipt": false,
"requestDeliveryReceipt": true
}

Configuration Reference​

Main Properties​

PropertyTypeRequiredDefaultDescription
configNamestring-Default configSMTP configuration alias
toarray✓-Recipient email addresses
ccarray--CC recipients
bccarray--BCC recipients (hidden)
subjectstring✓-Email subject line
bodystring✓-Email body content
isHtmlboolean-falseWhether body is HTML
fromEmailstring-From configOverride sender email
fromNamestring-From configOverride sender name
replyTostring--Reply-To address
priorityenum-NormalPriority: Low, Normal, High
attachmentsarray--File attachments
customHeadersobject--Custom email headers
requestReadReceiptboolean-falseRequest read receipt
requestDeliveryReceiptboolean-falseRequest delivery receipt

Attachment Properties​

PropertyTypeRequiredDescription
fileNamestring✓File name with extension
contentBase64string✓Base64-encoded file content
contentTypestring-MIME type (auto-detected if omitted)
isInlineboolean-Inline attachment for HTML
contentIdstring-Content ID for inline (use as cid:value)

For custom workers, see Your First Worker and Implementing Jobs.