SSL Send Mail with EFFS Attachment
Overview
This NetBurner application demonstrates how to send email messages with file attachments using SSL/TLS encryption and the EFFS (Embedded Flash File System) FAT32 file system. The application provides a web-based interface for configuring email settings and sending messages with attachments from SD/MMC cards or other supported storage devices.
Features
- Right-click project, select "Properties"
- Navigate to "C/C++ Builds -> Settings"
- Select "GNU C/C++ Linker -> Libraries"
- Add "StdFFile" to Libraries list
Application Components
Core Modules
- main.cpp: Main application entry point and initialization
- webfuncs.cpp: Web interface functions for email configuration and sending
- FileSystemUtils.cpp/h: File system utilities for EFFS operations
- effs_time.cpp/h: Time management functions (NTP, manual, RTC)
- ftp_f.cpp/h: FTP server implementation for file system access
- cardtype.h: Storage device type configuration
Web Interface
- index.html: Main configuration page for email settings
- Web form includes fields for:
- SMTP server settings (server, port, username, password)
- Email details (from, to, subject, message body)
- Attachment options (text creation, SD card file selection)
Getting Started
Hardware Requirements
- NetBurner development board from supported platforms
- SD/MMC card, SDHC card, or Compact Flash card (depending on configuration)
- Network connection (Ethernet)
- Storage device properly inserted and formatted as FAT32
Network Configuration
- Configure IP address, gateway, and DNS settings
- For DHCP, set IP address to 0.0.0.0 using IPSetup
- Ensure internet connectivity for NTP time synchronization
Email Server Configuration
The application uses SSL/TLS on port 465 by default. For Gmail:
- Server:
smtp.gmail.com
- Port:
465
- Enable "Less secure app access" or use an application-specific password
- For two-factor authentication, generate an app password at: https://myaccount.google.com/apppasswords
Usage
- Power on and Initialize: The device will automatically:
- Initialize the network stack
- Mount the storage device
- Synchronize time via NTP
- Start the web and FTP servers
- Access Web Interface: Connect to the device's IP address via HTTPS
- All connections must use HTTPS due to SSL configuration
- Configure Email Settings: Fill out the web form with:
- SMTP server credentials
- Email addresses and content
- Attachment options
- Send Email: Click "Send Mail" to transmit the email with attachments
File Management
The application includes an FTP server for convenient file management:
- Upload files to the storage device via FTP
- View and organize files on the SD card
- Prepare files for email attachment
Storage Device Support
The application supports multiple storage types through compile-time configuration:
- SD/MMC Cards: Standard SD and MultiMedia cards
- SDHC Cards: High-capacity SD cards
- Compact Flash: CF cards with appropriate hardware interface
- RAM Drive: In-memory file system for testing
Storage type is configured in cardtype.h
- only one type can be used at a time.
Security Features
- SSL/TLS Encryption: All SMTP communications are encrypted
- HTTPS Web Interface: Secure web-based configuration
- Authentication Support: SMTP username/password authentication
- Application Passwords: Support for modern email provider security
Error Handling
The application includes comprehensive error handling:
- EFFS file system error codes and descriptions
- Network timeout and retry mechanisms
- DNS resolution error reporting
- Detailed error logging for troubleshooting
Time Management
Accurate timestamps are maintained through:
- NTP Synchronization: Primary time source from internet time servers
- Manual Time Setting: Fallback when NTP is unavailable
- RTC Support: Real-time clock integration where available
- Timezone Configuration: Proper timezone handling for file timestamps
File System Operations
The EFFS utilities provide:
- File reading/writing operations
- Directory listing and navigation
- Space usage statistics
- File deletion and management
- Support for long filenames (platform dependent)
Development Notes
- The application uses the HCC Embedded EFFS FAT32 file system
- File system access requires proper task initialization with
f_enterFS()
- Multiple tasks can access the file system simultaneously (up to 10)
- Storage devices must be properly formatted as FAT32
- Write protection detection and handling included
Troubleshooting
Common Issues
- Storage Device Not Detected: Ensure card is properly inserted and supported
- Write Protection: Remove write protection from SD card
- Email Send Failures: Verify SMTP settings and network connectivity
- Time Sync Issues: Check internet connectivity for NTP
- File Access Errors: Ensure proper FAT32 formatting
Error Codes
The application provides detailed EFFS error codes for file system operations. Common errors include:
F_ERR_CARDREMOVED
: Storage device was removed
F_ERR_WRITEPROTECT
: Device is write-protected
F_ERR_NOTFORMATTED
: Device needs formatting
F_ERR_NOMOREENTRY
: Directory full