none
Send-MailMessage Timeout RRS feed

  • Question

  • Not sure if this is the right place or not. I developed a script that sends out notifications to users (about 1,000 each run) during the run my connection with Exchange times out. It appears that the e-mails actually don't get sent out until the script closes instead of open Exchange session, send email, Close Exchange Session.... Rinse and repeat until all emails are sent.

    Everything I've been reading is that this is way Send-MailMessage works? Is this true? Is there a way to send the e-mail as soon as I issue the Send-MailMessage cmdlet rather than opening the Exchange session and hold it open until the script completes?

    Wednesday, September 17, 2014 5:25 PM

Answers

  • Found out the problem and solution if you are interested. I wasn't using the -Credential switch so I was just letting Exchange authenticate the script as the currently logged on user. This caused Exchange to route my emails through a connector that has tarpinterval configured which would cause the problems. When I added the -Credential switch and used my test account credentials it used another connector that doesn't have tarpinterval configured and it worked.

    Thanks for your suggestions.


    • Marked as answer by BPurchell Wednesday, September 17, 2014 7:23 PM
    • Edited by BPurchell Wednesday, September 17, 2014 7:25 PM
    Wednesday, September 17, 2014 7:23 PM

All replies

  • Each email should get sent as soon as Send-MailMessage is invoked.

    I think it's more likely you may be hitting some throttling policy on the Exchange server that's designed to mitigate bulk spam or mailbombing attempts.  I'd check with the Exchange administrator and have them check the protocol logs.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    Wednesday, September 17, 2014 5:41 PM
    Moderator
  • Each email should get sent as soon as Send-MailMessage is invoked.

    I think it's more likely you may be hitting some throttling policy on the Exchange server that's designed to mitigate bulk spam or mailbombing attempts.  I'd check with the Exchange administrator and have them check the protocol logs.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    That's what I was thinking too from what I have been reading but my Exchange Architect said she isn't seeing any events in the Exchange logs indicating that a throttling policy was invoked. But the thing I don't get is when the script is running (I'm sending all the emails to a single test address as a stress test) none of the emails appear until the script concludes and I don't get all of them because in the processing the Exchange session times out. I would think it would open the session, send the email, then close the session.

    I shrunk my test file from 1000 emails to 100, but the same thing - it didn't send any of the emails until the script concluded.

    Wednesday, September 17, 2014 6:06 PM
  • Send more slowly.

    If your system has a spam filter then the spam filter will drop the connection if it sees spam.

    Why not just send to a distribution list?

    Where do you find this info that Exchange times out.  There is no connection to Exchange that times out.  Exchange never times out.  If you don't believe post your question in the Exchange forum.


    ¯\_(ツ)_/¯

    Wednesday, September 17, 2014 6:19 PM
  • You can send multiple emails in the same session, and it's actually much more efficient if it does. Are they looking at the protocol logs, or the message tracking logs?  

    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    Wednesday, September 17, 2014 6:25 PM
    Moderator
  • Found out the problem and solution if you are interested. I wasn't using the -Credential switch so I was just letting Exchange authenticate the script as the currently logged on user. This caused Exchange to route my emails through a connector that has tarpinterval configured which would cause the problems. When I added the -Credential switch and used my test account credentials it used another connector that doesn't have tarpinterval configured and it worked.

    Thanks for your suggestions.


    • Marked as answer by BPurchell Wednesday, September 17, 2014 7:23 PM
    • Edited by BPurchell Wednesday, September 17, 2014 7:25 PM
    Wednesday, September 17, 2014 7:23 PM
  • I noted.  Not an Exchange or scripting issue.

    ¯\_(ツ)_/¯

    Wednesday, September 17, 2014 7:31 PM