OrchardCMS/OrchardCore · error · InvalidOperationException

The SMTP pickup directory location is invalid.

Error message

The SMTP pickup directory location is invalid.

What it means

SmtpPickupDirectoryResolver.ResolvePickupDirectoryLocation validates the configured pickup directory location string and throws InvalidOperationException when it fails IsValidPickupDirectoryLocation (null, whitespace, or otherwise invalid path characters/shape). The base location is separately guaranteed non-blank via ArgumentException.

Solutions

  1. Set a valid absolute PickupDirectoryLocation in the SMTP settings (Features > Email SMTP settings).
  2. If the location equals the base, clear the per-location value so the base is used.
  3. Check the appsettings/recipe supplying SmtpSettings for an empty or malformed path.
  4. Use only valid path characters (no illegal filename characters, no empty string) for the value.

Example fix

// before (appsettings or SMTP settings)
"PickupDirectoryLocation": ""
// after
"PickupDirectoryLocation": "C:\\inetpub\\mailroot\\Pickup"
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrWhiteSpace(pickupDirectoryLocation))
    throw new InvalidOperationException("Configure a valid SMTP pickup directory location before saving.");

Try / catch

try { var dir = SmtpPickupDirectoryResolver.ResolvePickupDirectoryLocation(basePath, location); } catch (InvalidOperationException ex) when (ex.Message.Contains("pickup directory location is invalid")) { /* surface settings validation error to admin */ }

Prevention

When it happens

Trigger: SMTP settings have PickupDirectoryLocation set to an empty, whitespace-only, or invalid value; ConfigurePickupDirectory calls the resolver with that value and the validation check fails.

Common situations: Admin left the pickup directory field blank while selecting the pickup-directory delivery method; a config/recipe migration wiped the value; invalid characters pasted into the settings field.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/a267dade580d13cb. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore.Modules/OrchardCore.Email.Smtp/Services/SmtpPickupDirectoryResolver.cs:62

        ArgumentNullException.ThrowIfNull(shellSettings);

        var pickupDirectoryLocationBase = string.IsNullOrWhiteSpace(configuredBasePath)
            ? DefaultPickupDirectoryLocationBaseTemplate
            : configuredBasePath;

        var formattedPickupDirectoryLocationBase = ParseAndFormat(pickupDirectoryLocationBase, fluidParser, shellOptions, shellSettings);
        formattedPickupDirectoryLocationBase = NormalizeDirectorySeparators(formattedPickupDirectoryLocationBase);

        return Path.GetFullPath(formattedPickupDirectoryLocationBase);
    }

    public static string ResolvePickupDirectoryLocation(string pickupDirectoryLocationBase, string pickupDirectoryLocation)
    {
        ArgumentException.ThrowIfNullOrWhiteSpace(pickupDirectoryLocationBase);

        if (!IsValidPickupDirectoryLocation(pickupDirectoryLocation))
        {
            throw new InvalidOperationException("The SMTP pickup directory location is invalid.");
        }

        var normalizedPickupDirectoryLocation = NormalizePickupDirectoryLocation(pickupDirectoryLocation);

        var fullPickupDirectoryLocation = string.IsNullOrWhiteSpace(normalizedPickupDirectoryLocation)
            ? pickupDirectoryLocationBase
            : Path.GetFullPath(Path.Combine(pickupDirectoryLocationBase, normalizedPickupDirectoryLocation));

        if (!IsWithinBasePath(pickupDirectoryLocationBase, fullPickupDirectoryLocation))
        {
            throw new InvalidOperationException($"The SMTP pickup directory location '{pickupDirectoryLocation}' resolves outside the configured pickup directory base '{pickupDirectoryLocationBase}'.");
        }

        return fullPickupDirectoryLocation;
    }

    public static bool IsValidPickupDirectoryLocation(string pickupDirectoryLocation)
    {

View on GitHub (pinned to 4306c0717f)