Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


configure Exchange 2010 to requeue outbound mail to bypass failed upstream gateway

Posted on 2011-02-28
Medium Priority
Last Modified: 2012-05-11
I have one Exchange 2010 server with 2 upstream email gateways for antispam/antivirus filtering.  Outbound email can go through either gateway - both have send connectors.  The primary gateway's send connector is configured with a cost of 1, and the secondary with a cost of 3 so that mail goes through the primary when possible.  However when the primary fails mail backs up in it's Exchange queue.  Exchange does not seem to understand that the gateway is down, and refuses to requeue the mail to the secondary send connector.  

The result is that mail backs up until it expires, and it bounces back to the sender - even though there is a completely functional alternate send connector.  How do I configure Exchange to requeue mail through the secondary gateway when the primary's queue is filling up?
Question by:vreiner
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4

Expert Comment

by:J P
ID: 35003791
instead of two send connectors, make one send connector
but have multiple smart hosts in there [eg: the smarthost of connector1 and smarthost of connector2]

quote1: "If a smart hosted SMTP Send Connector has multiple smart hosts defined, load balancing and fault tolerance are accomplished using these smart hosts."
quote2: "Mail will not be load balanced among multiple equal cost connectors."
reference: http://msexchangeteam.com/archive/2007/01/04/432069.aspx (for E2007 but applies to E2010)

Author Comment

ID: 35004221
ok, this is a good clarification: I DO want fault tolerance but I do NOT want load balancing.  If I understand this correctly adding a second smart host to a single Send Connector will result in the traffic going to both smart hosts relatively equally.

The functioning of the spam filter software relies on a primary/secondary relationship, which is why I set up 2 send connectors with a higher cost on the secondary.  I want as much traffic as possible going through the primary gateway, and I really only want the secondary to be used if the primary cannot accept new connections (whether because it is at 100% capacity or because it is down).  Can I achieve fault tolerance WITHOUT load balancing using the method you describe, or by another method?

Expert Comment

by:J P
ID: 35005672
FT without LB is interesting request, i can understand the reasons for which you are asking for it..
off the top of my head, for only FT, it would involve manual intervention with two connectors..

eg: keep the two connectors, when one is down and things start queuing, change the cost of primary connector to be higher then the secondary, restart transport services to engage the second connector and that should allow queue to drain (think answers the very last bit of the original question)

thinking bit outside, there might be something out there that "checks if a smarthost is accepting mail okay, if so then keep its dns entry, if not change its dns entry to another working smarthost" if there is, just one connector and smarthost would suffice, because this "special program" would automatically change the dns associated to the smarthost to another one etc

hope this helps
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why


Author Comment

ID: 35012437
this is an interesting approach... but my goal is to make this automated, likely via a scheduled task running a script.  I assume that I could script both the change to the primary send connector's cost and to restart the transport services.  I can do some reading on those things.  

Question is: how would I detect that mail is queuing up? I am new to Ex2010 (was on 2003 before) and while I can write a decent batch file I'm not familiar with what is and is not possible with Exchange Management Shell, or other scripting/programming languages I might use with Exchange.  Is there some way to measure the number of items in the queue, or test if a smarthost has open connections to receive mail?  I'm just trying to think all around this topic.  


Assisted Solution

by:J P
J P earned 500 total points
ID: 35033683
not sure if you have scom or not, other options could be perfmon or ems script
here is a ems script which could do the job of "if queue has X mail queued, then change primary connector cost, restart transport service"
this would give the chance for your other connectors to 'takeover' the queued message and attempt to send them
script can be automated to run at scheduled intervals automated

$Queue = Get-TransportServer | Get-Queue | Measure-Object MessageCount -max
if ($Queue.Maximum -gt 88)
Set-SendConnector "SendConnector" -AddressSpaces "SMTP:*;100"
Restart-Service MSExchangeTransport

Open in new window

usage notes:
replace 88 with queue thresshold
replace SendConnector with your primary send connector name

Accepted Solution

vreiner earned 0 total points
ID: 35033898
I've found the solution: use MX records instead of the smarthost IP address or FQDN.  Exchange will check the MX weights and route mail accordingly, immediately moving to the next smarthost if one does not respond.  The solution is detailed here:


your solution was excellent as well and so I'm going to award you the points for your hard work.

Expert Comment

by:J P
ID: 35033942
interesting, using mx as smarthost, i learned something here also
thanks mate

Author Closing Comment

ID: 35067716
I found a more-effective solution using Microsoft's built-in functions, which work more quickly than the offered scripted solution.  However I felt that the offered solution was also accurate if not as effective or elegant so I awarded the points to that person.

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question