Kareadita/Kavita · error · KavitaException

send-to-kavita-email

Error message

send-to-kavita-email

What it means

Thrown by DeviceService.SendTo when the server's email/SMTP settings are not configured for send-to-device. IsEmailSetupForSendToDevice() returns false when either SmtpConfig.Host or SmtpConfig.SenderAddress is empty. This is a pre-flight check that fires before any device or file validation.

Source

Thrown at Kavita.Services/DeviceService.cs:104

            await readingProfileService.RemoveDeviceLinks(userWithDevices.Id, deviceId);

            if (!unitOfWork.HasChanges()) return true;
            if (await unitOfWork.CommitAsync(ct)) return true;
        }
        catch (Exception ex)
        {
            logger.LogError(ex, "There was an issue with deleting the device, {DeviceId} for user {UserName}", deviceId, userWithDevices.UserName);
        }

        return false;
    }

    public async Task<bool> SendTo(IReadOnlyList<int> chapterIds, int deviceId, CancellationToken ct = default)
    {
        var settings = await unitOfWork.SettingsRepository.GetSettingsDtoAsync(ct);
        if (!settings.IsEmailSetupForSendToDevice())
            throw new KavitaException("send-to-kavita-email");

        var device = await unitOfWork.DeviceRepository.GetDeviceById(deviceId, ct);
        if (device == null) throw new KavitaException("device-doesnt-exist");

        var files = await unitOfWork.ChapterRepository.GetFilesForChaptersAsync(chapterIds, ct);
        if (files.Any(f => f.Format is not (MangaFormat.Epub or MangaFormat.Pdf)) && device.Platform == EmailDevicePlatform.Kindle)
            throw new KavitaException("send-to-permission");

        // If the size of the files is too big
        if (files.Sum(f => f.Bytes) >= settings.SmtpConfig.SizeLimit)
            throw new KavitaException("send-to-size-limit");


        try
        {
            device.UpdateLastUsed();
            unitOfWork.DeviceRepository.Update(device);
            await unitOfWork.CommitAsync(ct);

View on GitHub (pinned to 9c3e540000)

Solutions

  1. Navigate to Server Settings > Email and configure the SMTP Host and Sender Address fields
  2. Verify the SMTP Host value is not empty and is the correct server hostname or IP
  3. Set the Sender Address to a valid email address that the SMTP server will accept
  4. Save settings and test the email configuration before retrying send-to-device

Example fix

// In Server Settings UI, set:
// SMTP Host: smtp.example.com
// SMTP Port: 587
// Sender Address: kavita@example.com
// Then Save and retry Send to Device.
Defensive patterns

Strategy: validation

Validate before calling

// Check SMTP configuration before allowing send-to-device:
// var settings = await unitOfWork.SettingsRepository.GetSettingsDtoAsync(ct);
// if (!settings.IsEmailSetupForSendToDevice()) {
//     return BadRequest("Email is not configured. Set up SMTP in Server Settings first.");
// }

Try / catch

// try {
//     await deviceService.SendTo(chapterIds, deviceId, ct);
// } catch (KavitaException ex) when (ex.Message == "send-to-kavita-email") {
//     return BadRequest(new { error = "SMTP email is not configured. Go to Server Settings > Email." });
// }

Prevention

When it happens

Trigger: Admin has not configured SMTP settings in the server configuration; SMTP host was set but sender address is blank; settings were partially configured and saved; SMTP config was cleared during a settings reset.

Common situations: Fresh Kavita installation where email was never set up; admin cleared SMTP settings to troubleshoot email issues; migration to a new server where SMTP config wasn't carried over; environment variable for SMTP host not set in container deployments.

Related errors


AI-assisted analysis of Kareadita/Kavita@9c3e540000 (2026-08-13). Data as JSON: /api/errors/d3389bf4419b2cf0. Report an issue: GitHub.