SSL/TLS Send Mail Example
A NetBurner embedded application that demonstrates secure email transmission using SSL/TLS protocols.
Overview
This application illustrates how to send email messages from a NetBurner device to mail servers that require SSL/TLS encryption. The implementation provides a web-based interface for configuring email settings and sending messages securely over HTTPS connections.
Key Features
- SSL/TLS encrypted email transmission
- Web-based configuration interface
- Support for both direct SSL and STARTTLS negotiation methods
- SMTP authentication support
- Network time synchronization via NTP
- File system utilities for external storage devices
SSL/TLS Connection Methods
The application supports two SSL/TLS handshake methods:
Direct SSL Connection
- Connects directly to SSL/TLS ports (465 or 587)
- Uses
SSL_connect for immediate secure connection
- Recommended for servers known to support SSL/TLS
- Suitable for services like Yahoo that expect SSL connections on specific ports
STARTTLS Method
- Initially connects to standard SMTP port 25
- Performs
EHLO command to check server capabilities
- If server responds with "STARTTLS", initiates SSL negotiation
- Required for Gmail and servers that mandate TLS encryption
Configuration Requirements
Network Setup
- Valid IP address, network mask, gateway, and DNS configuration
- Internet connectivity for NTP time synchronization and mail transmission
- DHCP support available (set IP address to 0.0.0.0 to enable)
Gmail Configuration
When connecting to Gmail accounts:
- Enable "less secure application access" in account settings
- For two-factor authentication accounts, create an application-specific password
- Use server:
smtp.gmail.com
- Use port:
465 or 587
- Leave STARTTLS unchecked
- Generate app passwords at: https://myaccount.google.com/apppasswords
Yahoo Configuration
- Requires premium services (mailplus or bizmail) - free accounts not supported
- Does not support STARTTLS detection
- Connect to port 465/587 for SSL or port 25 for non-SSL
Application Structure
Core Components
main.cpp**
File System Support
The application includes comprehensive file system utilities supporting:
- SD/MMC cards
- SDHC cards
- Compact Flash (CFC)
RAM drives
Supported Operations:**
- File creation, reading, writing, and deletion
- Directory management
- FTP server functionality
- Multiple storage device types
Usage Instructions
- Network Configuration
- Verify IP gateway and DNS settings
- Enable DHCP by setting IP to 0.0.0.0 (optional)
- Email Configuration
- Enter mail username and password
- Specify SMTP server hostname
- Set appropriate port (25, 465, or 587)
- Configure STARTTLS if required by server
- Send Email
- Fill in sender and recipient addresses
- Enter subject and message body
- Click "Send Mail" to transmit
Technical Implementation
Security Features
- SSL/TLS encryption for all mail transmission
- HTTPS web interface
- Secure credential handling
- DNS lookup validation
Error Handling
- Comprehensive DNS failure detection
- SSL connection error reporting
- File system error codes with descriptions
- Network timeout management
Development Requirements
NBEclipse Linker Configuration:** Add libStdFFile.a library:
- Right-click project, select "Properties"
- Navigate to "C/C++ Builds -> Settings"
- Select "GNU C/C++ Linker -> Libraries"
- Add "StdFFile" to Libraries list
Platform Support
- NetBurner embedded platforms
- Multiple storage device interfaces
- Real-time clock integration
- Timezone management with DST support
Error Codes and Troubleshooting
The application provides detailed error reporting for:
- File system operations (38 defined error codes)
- Network connectivity issues
- SSL/TLS handshake failures
- SMTP authentication problems
- DNS resolution failures