[Regression] RFC compliant localparts are rejected

Issue Description

Setting the localpart to ~ is rejected as invalid. This blocks the creation of some RFC complaint addresses.

Expected Behavior

A localpart that is RFC compliant should be accepted

Actual Behavior

Some valid localparts are rejected.

Reproduction Steps

  1. Create a user
  2. set localpart to ~
  3. “invalid localpart”

Stalwart Version

v0.16.x

Installation Method

Docker

Database Backend

RocksDB

Blob Storage

Filesystem

Search Engine

Internal

Directory Backend

Internal

Additional Context

This is a regression from v0.15 and i suspect it also affects other “non-conventional” localparts (like quoted). I think I have successfully bisected it to 4b5688fd where the “basic email sanitizer” might be a bit too basic.

I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.

on

I have searched this support forum (open and closed topics) and confirm this is not a duplicate.

on

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

Let me look into this to understand the current validation rules for email localparts.

Now let me look at the actual sanitize_email and sanitize_email_local implementations in utils/src/lib.rs:

Could I ask for a somewhat urgent fix, please? I would like to update and am using a mailbox with a Tilde in the localpart.