Sending Emails with SMTP in Delphi
Send emails through AhaSend’s SMTP servers using Delphi and the powerful Indy networking library. This guide covers everything from basic setup to advanced features like HTML content, attachments, and custom headers.Delphi & Indy Power: Delphi’s robust development environment combined with Indy’s comprehensive networking components provides excellent email capabilities for desktop and server applications.
Special Thanks: This guide was partly provided by Kirk, one of our amazing customers! We’re grateful for the Delphi community’s contributions and expertise in helping fellow developers integrate with AhaSend.
Prerequisites
Before you begin, ensure you have:Development Environment
Development Environment
- Delphi installed on your system (Delphi 10.3 or higher recommended)
- Indy networking library configured in your project
- Basic knowledge of Delphi/Object Pascal programming
- Access to Delphi’s component palette and IDE
AhaSend Setup
AhaSend Setup
- Domain verified in your AhaSend account
- SMTP credentials created (username and password)
- Access to your AhaSend dashboard for credential management
Indy Components
Indy Components
- TIdSMTP component for SMTP functionality
- TIdSSLIOHandlerSocketOpenSSL for secure connections
- TIdMessage for email message construction
- TIdEncoderMIME for encoding operations
Need SMTP Credentials? If you haven’t created SMTP credentials yet, check out our SMTP Credentials guide for step-by-step instructions.
Indy Components Overview
Delphi’s Indy library provides powerful networking components for email operations:TIdSMTP
Purpose: Main SMTP client component
Features: Connection, auth, sending
Security: TLS/SSL support
Location: Internet tab in component palette
Features: Connection, auth, sending
Security: TLS/SSL support
Location: Internet tab in component palette
TIdMessage
Purpose: Email message construction
Features: Headers, body, attachments
Encoding: MIME support
Location: Internet tab in component palette
Features: Headers, body, attachments
Encoding: MIME support
Location: Internet tab in component palette
Connection Settings
Use these settings for all Delphi SMTP configurations with AhaSend:Primary Server
Host:
Ports: 587 (recommended), 25, 2525
Security: STARTTLS
Authentication: Required
send.ahasend.com
Ports: 587 (recommended), 25, 2525
Security: STARTTLS
Authentication: Required
US Server
Host:
Ports: 587 (recommended), 25, 2525
Security: STARTTLS
Authentication: Required
send-us.ahasend.com
Ports: 587 (recommended), 25, 2525
Security: STARTTLS
Authentication: Required
Basic Email Examples
Component Setup
First, add the required Indy components to your form or data module:Basic Examples
Testing with Sandbox Mode
Use sandbox mode to safely test your Delphi email integration:Sandbox Benefits: Emails sent in sandbox mode are free, trigger webhooks normally, and never actually deliver to recipients - perfect for development and testing.