Setting up forwarding from Gmail?

Your question

Hi all,

I have a rule in my Google account that forwards all of my mail to my Stalwart hosted email address running on my personal domain.

However, it seems most of the forwarded mail arriving at Stalwart gets classified as spam, I think mostly because of these two rules:

FORGED_RCVD_TRAIL (1.00), FORGED_RECIPIENTS (2.00),

Is there a way to configure forwarding from Gmail that I’m not seeing? Should I just disable these two rules?

I tried searching for similar posts but most appear to be regarding outgoing mail, not incoming.

Thanks. :slight_smile:

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

Gmail forwarding keeps the original headers, so the envelope recipient (your Stalwart address) isn’t in To/Cc. The Received trail also looks odd because it comes from Google’s forwarding hop. Those two rules are heuristics that fire on any forwarded mail, so they aren’t a sign of misconfiguration. I don’t know of a Gmail-side setting that avoids this.

I’d avoid disabling the rules, since they also help catch real spam. These options are better:

  1. Exempt or favour Google’s forwarding servers with a negative-score tag. Add a rule that sets a local tag for the relevant sending IPs. For example, use the Any variant with a condition like if_then(remote_ip == '<google ip>', 'LOCAL_TRUSTED_RELAY', false). Then add a SpamTag that scores LOCAL_TRUSTED_RELAY at something like -5 to -20. The rest of the filter still runs, so obvious spam is still caught. The scores should offset the forwarding penalties without hiding genuinely bad mail.

  2. Skip filtering for those servers entirely. Edit the enableSpamFilter expression on the DATA stage, e.g. is_empty(authenticated_as) && remote_ip != '<ip>'. Be careful here: Gmail also relays mail from other senders, and all of it would then skip spam checks.

  3. Lower the score of the two tags. Define SpamTag entries with a reduced score for FORGED_RCVD_TRAIL and FORGED_RECIPIENTS. This affects all mail, not just Gmail’s.

  4. Rely on the trusted-sender overrides. trustContacts and trustReplies keep mail from your address book contacts, and replies to your own messages, out of Junk. Note that the contact check requires the original sender to pass DMARC.

Another option is to fetch Gmail from Stalwart instead of forwarding. This avoids the forwarding artefacts, but it’s a different setup, and I haven’t checked whether Stalwart supports it.

Details are in the Trusted senders page. To see the exact Google IPs and scores involved, check the X-Spam-Result header on a forwarded message.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

Hi,

FORGED_RCVD_TRAIL turned out to be a bug on our side. Google writes the reverse DNS name in its Received headers with a trailing dot (from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])), and the spam filter compared the two names literally, so every Gmail hop looked forged. The comparison now ignores that final dot, and the fix ships in the next weekly Stalwart release.

FORGED_RECIPIENTS is expected for forwarded mail: the message is addressed to your Gmail address, while the envelope recipient is your Stalwart address. I wouldn’t disable it globally, since it is a useful signal for everything else. You can offset it for your forwarded mail with a local rule plus a negative score, as described in Exempting a sender, domain or server. Gmail rewrites the envelope sender of forwarded messages to [email protected], so a rule of the Any variant like

if_then(starts_with(env_from, 'yourgmailuser+caf_='), 'LOCAL_GMAIL_FORWARD', false)

together with a SpamTag scoring LOCAL_GMAIL_FORWARD at something like -5 will cover it. Replace yourgmailuser with your Gmail local part.