Kareadita/Kavita · error · KavitaException
send-to-size-limit
Error message
send-to-size-limit
What it means
Thrown by DeviceService.SendTo when the combined byte size of all selected files meets or exceeds settings.SmtpConfig.SizeLimit. The check uses files.Sum(f => f.Bytes) >= SizeLimit, so hitting the exact limit also triggers it. This prevents sending oversized email attachments that the SMTP server would reject.
Source
Thrown at Kavita.Services/DeviceService.cs:115
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);
}
catch (Exception ex)
{
logger.LogError(ex, "There was an issue updating device last used time");
}
var success = await emailService.SendFilesToEmail(new SendToDto()
{
UserId = device.AppUserId,
DestinationEmail = device.EmailAddress!,
FilePaths = files.Select(m => m.FilePath)View on GitHub (pinned to 9c3e540000)
Solutions
- Select fewer chapters or smaller files to stay under the size limit
- Increase the SmtpConfig.SizeLimit in Server Settings to match the SMTP provider's maximum (verify the provider supports larger attachments)
- Split the send into multiple smaller batches, each under the limit
- Consider compressing or downsampling large files before adding them to the library
Example fix
// Before calling SendTo, check total size client-side:
// const totalBytes = selectedFiles.reduce((sum, f) => sum + f.bytes, 0);
// if (totalBytes >= smtpSizeLimit) {
// toast.error(`Total size ${formatBytes(totalBytes)} exceeds limit ${formatBytes(smtpSizeLimit)}. Remove some files.`);
// return;
// } Defensive patterns
Strategy: validation
Validate before calling
// Check total size before calling SendTo:
// var files = await unitOfWork.ChapterRepository.GetFilesForChaptersAsync(chapterIds, ct);
// var settings = await unitOfWork.SettingsRepository.GetSettingsDtoAsync(ct);
// var totalBytes = files.Sum(f => f.Bytes);
// if (totalBytes >= settings.SmtpConfig.SizeLimit) {
// return BadRequest($"Total size ({totalBytes / 1024 / 1024}MB) exceeds the limit ({settings.SmtpConfig.SizeLimit / 1024 / 1024}MB)");
// } Try / catch
// try {
// await deviceService.SendTo(chapterIds, deviceId, ct);
// } catch (KavitaException ex) when (ex.Message == "send-to-size-limit") {
// return BadRequest(new { error = "Total file size exceeds the SMTP size limit. Remove some files or increase the limit in settings." });
// } Prevention
- Display a running total of selected file sizes against the SMTP size limit in the UI
- Set the SMTP SizeLimit to match the provider's actual maximum (e.g., 25MB for Gmail)
- Guide users to send in smaller batches when the total exceeds the limit
When it happens
Trigger: User selects too many chapters or very large files (high-resolution PDFs, large epubs with embedded images) whose total exceeds the SMTP size limit; the SizeLimit is configured too low for the user's content.
Common situations: Sending a full volume of high-resolution manga to a device; SMTP provider has a strict attachment size cap (e.g., Gmail's 25MB limit); user hasn't adjusted the default SizeLimit to match their SMTP provider's actual cap.
Related errors
AI-assisted analysis of Kareadita/Kavita@9c3e540000 (2026-08-13).
Data as JSON: /api/errors/f7ef78112f52cb73.
Report an issue: GitHub.