Stopping recursive email loop

tdenson

Registered
Mar 28, 2016
3
0
1
UK
cPanel Access Level
Root Administrator
I wonder if someone can help me with the following. I have a requirement to forward Yahoo email to a domain which I manage with cpanel. However, I also want to forward email sent directly to that domain back to the yahoo account as well. Obviously this sets up a loop, which when I test empirically only loops once, leaving two copies of the original email in the Yahoo mailbox. Any bright ideas to make this work as I would like it to ?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Hello :)

You could setup an email filter in cPanel instead of setting up the forwarder with the "Forwarders" option:

Email Filters - Documentation - cPanel Documentation

Use multiple rules so the message is only forwarded to Yahoo if it's not a message that's not already been forwarded from the Yahoo account. This document is also helpful:

How to Configure Mail Filters - cPanel Knowledge Base - cPanel Documentation

Feel free to post the message header of one of the messages from Yahoo that you don't want forwarded (remove actual domain names and IP addresses) if you are unable to create the filter rules.

Thank you.
 

tdenson

Registered
Mar 28, 2016
3
0
1
UK
cPanel Access Level
Root Administrator
Hello :)

You could setup an email filter in cPanel instead of setting up the forwarder with the "Forwarders" option:

Email Filters - Documentation - cPanel Documentation

Use multiple rules so the message is only forwarded to Yahoo if it's not a message that's not already been forwarded from the Yahoo account. This document is also helpful:

How to Configure Mail Filters - cPanel Knowledge Base - cPanel Documentation

Feel free to post the message header of one of the messages from Yahoo that you don't want forwarded (remove actual domain names and IP addresses) if you are unable to create the filter rules.

Thank you.
I did read both of those documents before posting, but was unable to make anything work. Find below a copy of the full headers of the email forwarded from Yahoo (sanitised to remove personal information) -

Code:
Return-path: <[email protected]>
Envelope-to: [email][email protected][/email]
Delivery-date: Wed, 30 Mar 2016 00:38:52 +0300
Received: from nm16-vm9.bullet.mail.gq1.yahoo.com ([98.137.177.242]:44649)
    by one.deepafrica.com with esmtps (TLSv1.2:AES128-GCM-SHA256:128)
    (Exim 4.86_1)
    (envelope-from <[email protected]>)
    id 1al1Lf-003BIo-1i
    for [email][email protected][/email]; Wed, 30 Mar 2016 00:38:51 +0300
Received: from [216.39.60.181] by nm16.bullet.mail.gq1.yahoo.com with NNFMP; 29 Mar 2016 21:38:09 -0000
Received: from [98.137.12.206] by tm17.bullet.mail.gq1.yahoo.com with NNFMP; 29 Mar 2016 21:38:09 -0000
Received: from [127.0.0.1] by omp1014.mail.gq1.yahoo.com with NNFMP; 29 Mar 2016 21:38:09 -0000
X-Yahoo-Newman-Property: ymail-3
X-Yahoo-Newman-Id: [email][email protected][/email]1.yahoo.com
Received: by 98.137.12.250; Tue, 29 Mar 2016 21:38:08 +0000
X-Apparently-To: [email][email protected][/email]; Tue, 29 Mar 2016 21:38:08 +0000
Received-SPF: pass (domain of gmail.com designates 74.125.82.49 as permitted sender)
X-YMailISG: uTPocqwWLDtEif4gNOBcRmDtdi_R5NnNlFhmbcXXww7Ciof3
gyu_t2JFy6sgYyCMQFZhh4Q7cAXeDehySDf5RMbhCEksb8dOXfhXGqcgfm5G
1td9ElA8tX.Z9gVdJShMcE6kWYmJrKk_DWsbws3UDsTKraBVymx2IBwdAmdL
ruZvVrE5v6KCJcrkppGDuUWhdEAQpp6TaI5A2daYt81uRGGSHX26xNFRWd0V
CNVFKm16zp.M4.GuCixXZKEb82uq4LjzKbKrMkf2.knCAubllVEbuV6S9mL6
1HLJEdk_uRQLqO7uBCgQ8UzIJ.CgjVXEDTYk0MgN8zb_IDv0mtIbk32cEbk9
4Eu2x7YgaIKT0XQQIlasqbeYTCKdYrba886FdPsNp_6alIEZDGbH_dOp2vLI
0_ZWVpxAPYX91h0PCfqmCoooA38nwun09bXuj6aaNYNGYZ3w5irIP_bV_jCA
.r3S0ofKp08n63M_ps4Iv4GV0hjSZEtAXuI6NDDkADwQ2aAbVPk48HoJHkDl
aoFjBbUolnu4yE.Yv0uemoDS70ZP47lBMr1oLddsguM3u6qrM4Aps61QVL8P
yIEYA_vcFweSI2hGZFnAk8kerHUzUo869zVdY1ybiFGB0y5giVkzmoBMDhae
V9dtaqNIkKeVeMlwZ7KZmTUr1okS_ju5wRAQvG2w7CFh0sJOMH9o9x2ex5xH
trtkXR3q0GZL8wnQiZcdtnT.1kCUhdTz3POMuNJqf164iEQav6dOoWAFv5iM
dzv3p5LVjSzxz.npCW.oO0yC1qJE_92xIeVvlqtd8RXuToJjzPXXwudwW_3C
tgKzcMNuCC_rtIF3zs4_lKZfO4ugFtfI32pd8513y9UoGBEp8tQHheQu453g
e57D2naNYGSVoJV0SFGfJQXSUDKqtBwPRO2T25_zSmNfoe8PRmMIVfWG3ndL
xjqZs3fASC099SHyB.vIpTs.jkPxTtZT6AEUbc3pQjM3mVpx2Xdxab0bAb4f
yQ4bohTl1G9n8zChHZ5.50V75dRK8JD2rnkXSDUMCxuzeOwYJtN.yLaQdjkM
6KIQNxh36zhMgEoyHv8JAub7TIjXp0KYCp9rGtvI38R7fUoF0kLsE5TPsa.V
_Wnqe4gQ6rrpwienfho.bGdELs6s7oPxuTQ2zXIWvGGzVOJBZ3sNGuZDnlxx
XIoWZYiQqz5MBQssj2nupANYRSlqvAGjwHJGcXBJbSkHjqD9XxTxcR3dIkhj
Uk.qRLrumw.Qli1frbVsjrfyk9LMwPLaKGqkes3ymAjuvxuisrTBlmgCFh0N
MWilUlymUD8XHMqM2zfcHNZc.uPc18VJpAfseOs9CRhoVI4IcPNgzr9SkNWm
aJcM_cyloDpgXleFoWEWgw29Jj8110z.PVD3bGRYK0Dh5hQUgbwddYcOUBYz
jVvLoQHreMn5zHYvGLbkECUmOzhgPWwE326bzV46o6PzgzRR.Q--
X-Originating-IP: [74.125.82.49]
Authentication-Results: mta1571.mail.bf1.yahoo.com  from=gmail.com; domainkeys=neutral (no sig);  from=gmail.com; dkim=pass (ok)
Received: from 127.0.0.1  (EHLO mail-wm0-f49.google.com) (74.125.82.49)
  by mta1571.mail.bf1.yahoo.com with SMTPS; Tue, 29 Mar 2016 21:38:08 +0000
Received: by mail-wm0-f49.google.com with SMTP id p65so45466237wmp.0
        for <[email protected]>; Tue, 29 Mar 2016 14:38:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=from:content-transfer-encoding:subject:message-id:date:to
         :mime-version;
        bh=VAgC5MVP54VmvlcGQaMT2ZdmokXkhMKi/RNSpcUu2qw=;
        b=wed8smSw6UPIFLDmDYq6y2e567CL7z3KiYT7T5jwVO4b8HChjVgFSS4haMh/KaE/Nz
         4rv9cDSkmZh5KIUPc3YUry+eK9F+ndJ6EDqyXlLq1ys41y9o/46ZCyu253+TW5drosdL
         QTS8TvbKWUETJpp5Vg2xFrnSmuHYaEX7sRpGtScuIHPXQemdTK5QQrbxt7+9NvJqqouf
         0xAu2Q2WiNKw/IA28v4foLNyH89Yvu9fXPlVzAISzRPzm7AQ74ooxq47lTgAFQY9vZ31
         9gQyWZ8RaZRWe1RtE7oBbWWdXS3+l8JVlr9gAiSIC3g++SG+ZMzsyBgeB/bNwc8YzdTW
         iB7w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:content-transfer-encoding:subject
         :message-id:date:to:mime-version;
        bh=VAgC5MVP54VmvlcGQaMT2ZdmokXkhMKi/RNSpcUu2qw=;
        b=VmNkJPcNkD8/zQZgvdMcfvrS5CJmKoawytHIBUrK5fJyx96TFLHU61Q2PTNqZZvsd/
         OFAVE1UvRtQBY+xwMRdwg0rrbaufVh7JddGEnSFLzX+T9Uo5g0lcdSRf1L88UP0DUcS0
         vrDnArAH6efMaSk+BXoC9Gkrb+VU8d/MCOtPZIXTHmJZFP99tbOvKZpRvP8p9fmk8jg5
         BHSCJanA6dCTb51PKNqxjMTQew+C10rF3uW0YGrOQF96ZbI70Qxv+4gv9w7yrqrhXf7z
         dszGyvreqU+qSEgS3aB01LZvbM807GjXk3ukKJ7qbdzNZiSYOBPmCEvC7ZLJyHP9FImH
         +cdw==
X-Gm-Message-State: AD7BkJIze8ICy3nhk0PAsQtD/tEiDNFKapOpWbPNon+0ntswXNUcPF+fcpqhjK0zTY9qEQ==
X-Received: by 10.194.189.143 with SMTP id gi15mr5016623wjc.54.1459287487567;
        Tue, 29 Mar 2016 14:38:07 -0700 (PDT)
Received: from [10.1.1.90] (cpc30-seac19-2-0-cust158.7-2.cable.virginm.net. [81.97.198.159])
        by smtp.gmail.com with ESMTPSA id t8sm593595wjy.41.2016.03.29.14.38.06
        for <[email protected]>
        (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);
        Tue, 29 Mar 2016 14:38:06 -0700 (PDT)
From: Fred Bloggs <[email protected]>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Subject: Test of Yahoo forward
Message-Id: <[email protected]>
Date: Tue, 29 Mar 2016 22:38:06 +0100
To: [email][email protected][/email]
Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\))
X-Mailer: Apple Mail (2.3124)
X-Yahoo-Forwarded: From [email][email protected][/email] To [email][email protected][/email]
Content-Length: 8
X-Spam-Status: No, score=-0.5
X-Spam-Score: -4
X-Spam-Bar: /
X-Ham-Report: Spam detection software, running on the system "one.deepafrica.com",
has NOT identified this incoming email as spam.  The original
message has been attached to this so you can view it or label
similar future email.  If you have any questions, see
root\@localhost for details.

Content preview:  Testing [...]

Content analysis details:   (-0.5 points, 5.0 required)

  pts rule name              description
---- ---------------------- --------------------------------------------------
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail provider
                             (myname[at]gmail.com)
  1.5 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
                             [score: 0.0000]
-0.1 DKIM_VALID_AU          Message has a valid DKIM or DK signature from author's
                             domain
-0.1 DKIM_VALID             Message has at least one valid DKIM or DK signature
  0.1 DKIM_SIGNED            Message has a DKIM or DK signature, not necessarily valid
-0.0 RCVD_IN_MSPIKE_H2      RBL: Average reputation (+2)
                             [98.137.177.242 listed in wl.mailspike.net]
X-Spam-Flag: NO

Testing
 

tdenson

Registered
Mar 28, 2016
3
0
1
UK
cPanel Access Level
Root Administrator
A further question related to this -

In the cpanel filter rules Actions section, is there a difference between send to email where email is original target (i.e. my domain), and deliver to folder INBOX ? Would the latter circumvent the subsequent forwarding back to the Yahoo address ?

Hello :)

You could setup an email filter in cPanel instead of setting up the forwarder with the "Forwarders" option:

Email Filters - Documentation - cPanel Documentation

Use multiple rules so the message is only forwarded to Yahoo if it's not a message that's not already been forwarded from the Yahoo account. This document is also helpful:
My conceptual problem with this is that the cpanel filters only apply to incoming mail, not outgoing forwards which is what I'm trying to filter.
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
In the cpanel filter rules Actions section, is there a difference between send to email where email is original target (i.e. my domain), and deliver to folder INBOX ?
Yes, choosing to deliver to a folder will place those emails in a specific folder within that email account as opposed to forwarding the address.

My conceptual problem with this is that the cpanel filters only apply to incoming mail, not outgoing forwards which is what I'm trying to filter.
You can configure outgoing email filters, however it requires manual intervention. Here's a thread and document that should help:

Easiest way to block all outgoing mail to a domain
How to Customize the Exim System Filter File - cPanel Knowledge Base - cPanel Documentation

Thank you.