
# Enhanced Email Service: SSL Support and Extended Timeouts ## Problem Statement The current `EmailService` has two significant limitations: 1. **Hardcoded short timeouts (15 seconds)** that cause failures with slow SMTP servers, particularly cPanel and shared hosting providers 2. **Missing SSL support** for port 465 connections - only STARTTLS is supported This results in timeout errors when using SMTP servers that require longer response times or SSL connections. ## Changes Made ### 1. Extended Timeouts - **Increased default timeouts from 15 seconds to 60 seconds** - Added configurable timeouts via system properties - Added write timeout configuration (previously missing) **Before:** ```java mailProps.put("mail.smtp.connectiontimeout", 15000); // 15 seconds mailProps.put("mail.smtp.timeout", 15000); // 15 seconds ``` **After:** ```java mailProps.put("mail.smtp.connectiontimeout", 60000); // 60 seconds mailProps.put("mail.smtp.timeout", 60000); // 60 seconds mailProps.put("mail.smtp.writetimeout", 60000); // 60 seconds (new) ``` ### 2. Full SSL Support - **Added SSL configuration for port 465** - **Auto-detection based on port and `ssl_enable` field** - **Enhanced security with modern TLS protocols** **New SSL Configuration:** ```java mailProps.put("mail.transport.protocol", "smtps"); mailProps.put("mail.smtp.ssl.enable", "true"); mailProps.put("mail.smtp.ssl.trust", emailProvider.getHost()); mailProps.put("mail.smtp.ssl.protocols", "TLSv1.2,TLSv1.3"); ``` ### 3. Improved Connection Type Detection - **Automatic detection** of SSL, STARTTLS, or plain connections - **Support for `ssl_enable` database field** - **Port-based auto-configuration** (465=SSL, 587=STARTTLS) ### 4. Enhanced Debugging and Logging - **Configurable debug mode** via system properties - **Detailed connection type logging** - **Better error context** for troubleshooting ## Database Schema Compatibility This enhancement works with the existing database schema and is **fully backward compatible**. It also supports the enhanced schema with `ssl_enable` and `connection_type` fields: ```sql ALTER TABLE email_provider ADD COLUMN ssl_enable BOOLEAN NOT NULL DEFAULT FALSE, ADD COLUMN connection_type VARCHAR(20) NOT NULL DEFAULT 'STARTTLS'; ``` ## Configuration Examples ### SSL (Port 465) ``` Host: smtp.gmail.com Port: 465 ssl_enable: true start_tls: false ``` ### STARTTLS (Port 587) ``` Host: smtp.gmail.com Port: 587 ssl_enable: false start_tls: true ``` ### Auto-Detection - **Port 465** → Automatically configured as SSL - **Port 587 + start_tls=true** → Automatically configured as STARTTLS - **ssl_enable=true** → Forces SSL regardless of port ## System Property Overrides Timeouts can be customized via system properties: ```bash -Dmail.smtp.connectiontimeout=30000 -Dmail.smtp.timeout=30000 -Dmail.smtp.writetimeout=30000 -Dmail.debug=true ``` ## Benefits 1. **Broader SMTP Server Compatibility** - Works with cPanel, Exchange, and slow SMTP servers 2. **Enhanced Security** - Full SSL support with modern TLS protocols 3. **Better Reliability** - Extended timeouts prevent premature failures 4. **Improved Debugging** - Better logging and configurable debug mode 5. **Backward Compatibility** - No breaking changes to existing configurations ## Testing This enhancement has been tested with: - ✅ cPanel SMTP servers (both SSL and STARTTLS) - ✅ Gmail SMTP (ports 465 and 587) - ✅ Corporate Exchange servers - ✅ Various shared hosting providers ## Impact - **Fixes timeout issues** with slow SMTP servers - **Enables SSL email providers** that were previously unsupported - **Maintains full backward compatibility** - **No database migration required** (but supports enhanced schema) --- **This fix resolves timeout issues reported by users with cPanel and other slow SMTP providers while adding comprehensive SSL support for enhanced security.**
BookLore
BookLore is a self-hosted web app for organizing and managing your personal book collection. It provides an intuitive interface to browse, read, and track your progress across PDFs and eBooks. With robust metadata management, multi-user support, and a sleek, modern UI, BookLore makes it easy to build and explore your personal library.
✨ Key Features
- 📚 Organized Book Management - Categorize books with Libraries and Shelves for easy discovery and structured organization.
- 🧠 Smart Metadata Handling - Automatically fetch book details from Goodreads, Amazon, and Google Books, or edit them manually with fine-grained control.
- 👥 Multi-User Support - Admins can create accounts, assign libraries, and manage permissions for metadata edits, uploads, and downloads.
- 📖 Built-in PDF & ePub Reader - A fast, feature-rich reader for PDFs and ePubs, with customizable reading settings and a clean UI.
- 🌐 OPDS 1.2 Support - Browse and download books through the Open Publication Distribution System – compatible with many reading apps.
- 🔐 Optional OIDC Authentication - Secure access with OpenID Connect, supporting both local JWT authentication and external providers like Authentik.
- 📤 Multi-Book Uploads - Upload multiple books at once with metadata auto-detection and file organization.
- 📧 Send Books via Email - Share books directly with others by sending them via email – quick and easy.
- 🚀 Continuous Improvements - Frequent updates with new features, performance enhancements, and UI improvements. BookLore is perfect for self-hosters who want complete control over their digital library. Stay tuned for updates!
🎥 Video Guides & Tutorials
For a step-by-step walkthrough, check out the official BookLore video guides on YouTube:
📺 BookLore Tutorials – YouTube
These videos cover deployment, configuration, and feature highlights to help you get started quickly.
🐳 Deploy with Docker
You can quickly set up and run BookLore using Docker.
1️⃣ Install Docker & Docker Compose
Ensure you have Docker and Docker Compose installed.
2️⃣ Create docker-compose.yml
Create a docker-compose.yml
file with content:
services:
booklore:
image: ghcr.io/adityachandelgit/booklore-app:latest
container_name: booklore
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- DATABASE_URL=jdbc:mariadb://mariadb:3306/booklore # Only modify this if you're familiar with JDBC and your database setup
- DATABASE_USERNAME=booklore # Must match MYSQL_USER defined in the mariadb container
- DATABASE_PASSWORD=your_secure_password # Use a strong password; must match MYSQL_PASSWORD defined in the mariadb container
- SWAGGER_ENABLED=false # Enable or disable Swagger UI (API docs). Set to 'true' to allow access; 'false' to block access (recommended for production).
depends_on:
mariadb:
condition: service_healthy
ports:
- "6060:6060"
volumes:
- /your/local/path/to/booklore/data:/app/data
- /your/local/path/to/booklore/books:/books
restart: unless-stopped
mariadb:
image: lscr.io/linuxserver/mariadb:11.4.5
container_name: mariadb
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- MYSQL_ROOT_PASSWORD=super_secure_password # Use a strong password for the database's root user, should be different from MYSQL_PASSWORD
- MYSQL_DATABASE=booklore
- MYSQL_USER=booklore # Must match DATABASE_USERNAME defined in the booklore container
- MYSQL_PASSWORD=your_secure_password # Use a strong password; must match DATABASE_PASSWORD defined in the booklore container
volumes:
- /your/local/path/to/mariadb/config:/config
restart: unless-stopped
healthcheck:
test: ["CMD", "mariadb-admin", "ping", "-h", "localhost"]
interval: 5s
timeout: 5s
retries: 10
Note: You can find the latest BookLore image tag BOOKLORE_IMAGE_TAG
(e.g. v.0.x.x) from the Releases section:
📦 Latest Image Tag – GitHub Releases
3️⃣ Start the Containers
Run the following command to start the services:
docker compose up -d
4️⃣ Access BookLore
Once the containers are up, access BookLore in your browser at:
http://localhost:6060
🔑 OIDC/OAuth2 Authentication (Authentik, Pocket ID, etc.)
BookLore supports optional OIDC/OAuth2 authentication for secure access. This feature allows you to integrate external authentication providers for a seamless login experience.
While the integration has been tested with Authentik and Pocket ID, it should work with other OIDC providers like Authelia as well. The setup allows you to use either JWT-based local authentication or external providers, giving users the flexibility to choose their preferred method.
For detailed instructions on setting up OIDC authentication:
🔐 Remote Authentication (Trusted Header SSO, Forward Auth)
If you run BookLore behind a reverse proxy with remote authentication (middleware),
you can enable automatic login by setting REMOTE_AUTH_ENABLED
to true
.
This allows you to use your existing authentication system (e.g., OAuth, SAML) to log in to BookLore.
The following remote auth environment variables can be configured:
Variable Name | Description | Default Value |
---|---|---|
REMOTE_AUTH_ENABLED | Enable remote authentication | false |
REMOTE_AUTH_CREATE_NEW_USERS | Auto-create users from remote auth | true |
REMOTE_AUTH_HEADER_NAME | HTTP header containing user's name | Remote-Name |
REMOTE_AUTH_HEADER_USER | HTTP header containing username | Remote-User |
REMOTE_AUTH_HEADER_EMAIL | HTTP header containing user's email | Remote-Email |
REMOTE_AUTH_HEADER_GROUPS | HTTP header containing user's groups | Remote-Groups |
REMOTE_AUTH_ADMIN_GROUP | Group name that grants admin privileges | - |
Example implementations:
- https://www.authelia.com/integration/trusted-header-sso/introduction/
- https://caddyserver.com/docs/caddyfile/directives/forward_auth
- https://doc.traefik.io/traefik/middlewares/http/forwardauth/
- https://github.com/sevensolutions/traefik-oidc-auth (Traefik OIDC Auth)
🤝 Community & Support
- 🐞 Found a bug? Open an issue
- ✨ Want to contribute? Check out CONTRIBUTING.md
- 💬 Ask questions or share feedback: Discussions
- 💬 Join our Discord: Click here to chat with the community
👨💻 Contributors & Developers
Thanks to all the amazing people who contribute to Booklore.
⭐ Star History
💖 Support the Project
If you find BookLore helpful, consider ⭐ starring the repo!
Or support the project via Venmo:
🧰 Tech Stack
⚖️ License
- GNU GPL v3
- Copyright 2024-2025