Back to Top

Help & Support

Get instant answers 24/7

This article is intended to help resolve this error:

550 5.7.1 Cannot forward message. To forward mail "From" an external domain, the Return-Path (or recipient) must belong to example.com (or a related domain aliases)

If you are using Postfix with our Outbound filtering system, and you need to forward your incoming messages, you may need to enable Sender Rewriting Scheme (SRS - http://www.openspf.org/SRS) for these forwards. This will cause the messages being forwarded to use your domain name, so our outbound filter will allow the messages to pass.

  • Ensure you have PCRE support installed for Postfix:

    sudo apt-install postfix-pcre
  • Create and edit a file which will contain the regular expression for changing the sender address:

    sudo vi /etc/postfix/canonical
  • Add this line to the new file, but replace yourDomain.com with your actual domain (this must be either subscribed or aliased on your SpamHero account):

    /^.*@(?!yourDomain\.com).*$/ bounce@yourDomain.com
  • Map the new changes into Postfix compatibility:

    postmap pcre:/etc/postfix/canonical
  • Add this to your /etc/postfix/main.cf file:

    canonical_maps = pcre:/etc/postfix/canonical
    canonical_classes = envelope_sender
  • Reload the Postfix configuration:

    postfix reload

This will set the Return-Path address for your outbound mail to bounce@[yourDomain.com], which will be accepted by SpamHero.

Last updated September 26, 2023