Community Discussions and Support
Outgoing mail rules loop

Sounds like a good idea to make a collection of useful rule samples. There has of course been various examples here in the forum and in the Mercury mailing list over the years, but they haven't been collected anywhere. The wiki would perhaps be the best place for it.

/Rolf

<p>Sounds like a good idea to make a collection of useful rule samples. There has of course been various examples here in the forum and in the Mercury mailing list over the years, but they haven't been collected anywhere. The wiki would perhaps be the best place for it. </p><p>/Rolf </p>

Hello,

I want outgoing e-mails from an application to be forwarded / copied to a mailbox

i.e.

the app mails as invoice@mydomain.com (from address) to different addresses.

copies of this outgoing e-mail should be sent to invoices@mydomain.com

However this always ends up in a loop as the forwarded mail goes out it is regarded as new e-mail that needs processing.

Mercury functions as an in between smtp server. No local addresses.

Using S & C

Somehow I had this working in the past but can't reproduce.

 

Thanks

<p>Hello,</p><p>I want outgoing e-mails from an application to be forwarded / copied to a mailbox</p><p>i.e.</p><p>the app mails as invoice@mydomain.com (from address) to different addresses.</p><p>copies of this outgoing e-mail should be sent to invoices@mydomain.com</p><p>However this always ends up in a loop as the forwarded mail goes out it is regarded as new e-mail that needs processing.</p><p>Mercury functions as an in between smtp server. No local addresses.</p><p>Using S & C</p><p>Somehow I had this working in the past but can't reproduce.</p><p> </p><p>Thanks </p>

Try this:

Outgoing rules

Expression NOT X-Autoforward: 1*   Headers only   Forward message

/Rolf

<p>Try this:</p><blockquote><p><i>Outgoing rules</i></p><p><i>Expression NOT X-Autoforward: 1*   Headers only   Forward message </i></p></blockquote><p>/Rolf </p>

Thanks for your suggestion but already the first forwarded message has the X-Autoforward entry in the header and is not sent. So no result. Nothing being forwarded

 I tried

if from invoice@mydomain.com forward invoices@mydomain.com

and

always exit from rule processing

 

This also has no effect. The original message is sent and a forward message is generated. This is obviously seen as a new message so rule processing starts from the top.

I start to believe that what we want is not possible but wonder what we did before.

We tried Mercury and were happy with the result. Then we bought the license to make sure mercury is always running and now we cannot reproduce. If we managed before what I really start to doubt now.

 

Thanks

 

<p>Thanks for your suggestion but already the first forwarded message has the X-Autoforward entry in the header and is not sent. So no result. Nothing being forwarded</p><p> I tried</p><p>if from invoice@mydomain.com forward invoices@mydomain.com</p><p>and</p><p>always exit from rule processing</p><p> </p><p>This also has no effect. The original message is sent and a forward message is generated. This is obviously seen as a new message so rule processing starts from the top. </p><p>I start to believe that what we want is not possible but wonder what we did before.</p><p>We tried Mercury and were happy with the result. Then we bought the license to make sure mercury is always running and now we cannot reproduce. If we managed before what I really start to doubt now.</p><p> </p><p>Thanks </p><p> </p>

Actually it should work like this:

The original message, that shouldn't contain any X-Autoforward header as it's just been generated, will trigger the rule (to create a second job with the X-Autoforward header) and get delivered normally to the recipient. The second job will not trigger the rule as it contains the X-Autoforward header, but will get delivered to the forwarding address.

If you send other mail as well through this server you may need to add an if from invoice@mydomain.com rule of course.

/Rolf

 

<p>Actually it should work like this:</p><p>The original message, that shouldn't contain any X-Autoforward header as it's just been generated, will trigger the rule (to create a second job with the X-Autoforward header) and get delivered normally to the recipient. The second job will not trigger the rule as it contains the X-Autoforward header, but will get delivered to the forwarding address.</p><p>If you send other mail as well through this server you may need to add an<i> if from invoice@mydomain.com</i> rule of course. </p><p>/Rolf </p><p>  </p>

I understand your reasoning and would like to see it working on this system but.........

Mercury Outgoing Rules
If header "F" contains "invoice@mydomain.com" Forward "invoices@mydomain.com"
Disabled If expression headers matches "NOT \"X-Autoforward: 1*\"" Forward "invoices@mydomain.com"

 

Above the ORULES.MER file content. No other Rules. (e-mail addresses modified :-) )

Currently the rules generate a loop.

If I disable rule 1 and enable rule 2 nothing happens, mail sent no copy or forward.

Something wrong in the rule ?, even copied the X-Autoforward: 1 from an e-mail to prevent typos. Anywhere else mistakes ??

Thanks.

 

<p>I understand your reasoning and would like to see it working on this system but......... </p><p>Mercury Outgoing Rules If header "F" contains "invoice@mydomain.com" Forward "invoices@mydomain.com" Disabled If expression headers matches "NOT \"X-Autoforward: 1*\"" Forward "invoices@mydomain.com"</p><p> </p><p>Above the ORULES.MER file content. No other Rules. (e-mail addresses modified :-) ) </p><p>Currently the rules generate a loop.</p><p>If I disable rule 1 and enable rule 2 nothing happens, mail sent no copy or forward. </p><p>Something wrong in the rule ?, even copied the X-Autoforward: 1 from an e-mail to prevent typos. Anywhere else mistakes ??</p><p>Thanks. </p><p>  </p>

I think you may have missed the "not" button. Copy this to ORULES.mer:

Mercury Outgoing Rules

If header "F" contains "invoice@mydomain.com" LogicalAnd ""

If not expression headers matches "X-Autoforward: 1*" Forward "invoices@mydomain.com"

/Rolf

<p>I think you may have missed the "not" button. Copy this to ORULES.mer:</p><blockquote><p><i>Mercury Outgoing Rules</i></p><p><i>If header "F" contains "invoice@mydomain.com" LogicalAnd ""</i></p><p><i>If not expression headers matches "X-Autoforward: 1*" Forward "invoices@mydomain.com"</i></p></blockquote><p>/Rolf </p>

Aargh, THE NOT BUTTON.

 

You are right. I added the NOT in the expression.

Now it works again. Thanks.

 

Looking back on the silly solution is there a location with more Rules samples ?

The help in Mercury is quite limited and is more a quick starter for a trial and error process.

 

Thanks anyway for the correct solution.

Aargh, THE NOT BUTTON.   You are right. I added the NOT in the expression. Now it works again. Thanks.   Looking back on the silly solution is there a location with more Rules samples ? The help in Mercury is quite limited and is more a quick starter for a trial and error process.   Thanks anyway for the correct solution.
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft