Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Stop the smtp service on an Exchange 2007 server?

Reply
 
Old 07-18-2007   #1 (permalink)
SuneR


 
 

Stop the smtp service on an Exchange 2007 server?

We are in the process of getting a good mail reputation with hotmail.com, and
hotmail.com wants us to stop sending them mail if they send us a 421 smtp
code. That means we reached the limit, and that we should stop further
sending to avoid getting a negative rep for that delivery.

I am already looking into a solution with rules on an Exchange 2007 Edge
Transport server, but so far no luck. But because I figure that no matter
what, Powershell is a good approach to stop the mails from being sent to
hotmail, that is why I ask here.

What I have in mind is something like this:

Make a powershell script that parses the logfile at intervals, and if it
finds an smtp code 421 from hotmail, it will simply stop the smtp service on
the server, I know that this means that mail to all other domains will be
stopped also, but stopping mail to hotmail is top priority in this process,
so a solution where the script stops the outgoing queue or enables a filter
to stop outgoing mail to hotmail would be better but I dont know if thats
easier/possible.

However, I am not skilled enough to make this script without help - and I
dont even know if this is a usable solution. So if anyone can give me some
tips, a script that can do some or all of what I am looking for I would be
very grateful!

I know this is not an Exchange forum, but if someone knows about Exchange
and knows of a better way to solve this, I am also very interested in
learning more about it.

My System SpecsSystem Spec
Old 07-18-2007   #2 (permalink)
Rob Campbell


 
 

RE: Stop the smtp service on an Exchange 2007 server?

First thing to do is find and example of a log entry of a connection to
hotmail that resulted in a 421. Once you have that you can start writing
your filter.

"SuneR" wrote:

> We are in the process of getting a good mail reputation with hotmail.com, and
> hotmail.com wants us to stop sending them mail if they send us a 421 smtp
> code. That means we reached the limit, and that we should stop further
> sending to avoid getting a negative rep for that delivery.
>
> I am already looking into a solution with rules on an Exchange 2007 Edge
> Transport server, but so far no luck. But because I figure that no matter
> what, Powershell is a good approach to stop the mails from being sent to
> hotmail, that is why I ask here.
>
> What I have in mind is something like this:
>
> Make a powershell script that parses the logfile at intervals, and if it
> finds an smtp code 421 from hotmail, it will simply stop the smtp service on
> the server, I know that this means that mail to all other domains will be
> stopped also, but stopping mail to hotmail is top priority in this process,
> so a solution where the script stops the outgoing queue or enables a filter
> to stop outgoing mail to hotmail would be better but I dont know if thats
> easier/possible.
>
> However, I am not skilled enough to make this script without help - and I
> dont even know if this is a usable solution. So if anyone can give me some
> tips, a script that can do some or all of what I am looking for I would be
> very grateful!
>
> I know this is not an Exchange forum, but if someone knows about Exchange
> and knows of a better way to solve this, I am also very interested in
> learning more about it.

My System SpecsSystem Spec
Old 07-18-2007   #3 (permalink)
SuneR


 
 

RE: Stop the smtp service on an Exchange 2007 server?

That is true, and that is what I am planning to do.

Maybe I fail to explain myself, but I am more interested in where and how I
can make this filter. Exactly how the filter should get triggered is for me
to figure out, by looking at the log file. But I am rather clueless as to how
to stop the mails form being sent after my filter is triggered.

Right now Im thinking that a scheduled job that read the log every 5 minutes
is the way to go, but as I wrote below, this is all very new to me, so there
might be a better and cleaner way to do it.

I know the

"Rob Campbell" wrote:

> First thing to do is find and example of a log entry of a connection to
> hotmail that resulted in a 421. Once you have that you can start writing
> your filter.
>
> "SuneR" wrote:
>
> > We are in the process of getting a good mail reputation with hotmail.com, and
> > hotmail.com wants us to stop sending them mail if they send us a 421 smtp
> > code. That means we reached the limit, and that we should stop further
> > sending to avoid getting a negative rep for that delivery.
> >
> > I am already looking into a solution with rules on an Exchange 2007 Edge
> > Transport server, but so far no luck. But because I figure that no matter
> > what, Powershell is a good approach to stop the mails from being sent to
> > hotmail, that is why I ask here.
> >
> > What I have in mind is something like this:
> >
> > Make a powershell script that parses the logfile at intervals, and if it
> > finds an smtp code 421 from hotmail, it will simply stop the smtp service on
> > the server, I know that this means that mail to all other domains will be
> > stopped also, but stopping mail to hotmail is top priority in this process,
> > so a solution where the script stops the outgoing queue or enables a filter
> > to stop outgoing mail to hotmail would be better but I dont know if thats
> > easier/possible.
> >
> > However, I am not skilled enough to make this script without help - and I
> > dont even know if this is a usable solution. So if anyone can give me some
> > tips, a script that can do some or all of what I am looking for I would be
> > very grateful!
> >
> > I know this is not an Exchange forum, but if someone knows about Exchange
> > and knows of a better way to solve this, I am also very interested in
> > learning more about it.

My System SpecsSystem Spec
Old 07-18-2007   #4 (permalink)
Marco Shaw


 
 

Re: Stop the smtp service on an Exchange 2007 server?

Rob Campbell wrote:
> First thing to do is find and example of a log entry of a connection to
> hotmail that resulted in a 421. Once you have that you can start writing
> your filter.


The "filter" would be a "transport rule"?

Marco
My System SpecsSystem Spec
Old 07-18-2007   #5 (permalink)
Rob Campbell


 
 

RE: Stop the smtp service on an Exchange 2007 server?

I'd look at using a scheduled task to start the script, and periodically
check to make sure it's still running, but write the script itself to start
up and stay resident, using a sleep timer to trigger a processing cycle.

"SuneR" wrote:

> We are in the process of getting a good mail reputation with hotmail.com, and
> hotmail.com wants us to stop sending them mail if they send us a 421 smtp
> code. That means we reached the limit, and that we should stop further
> sending to avoid getting a negative rep for that delivery.
>
> I am already looking into a solution with rules on an Exchange 2007 Edge
> Transport server, but so far no luck. But because I figure that no matter
> what, Powershell is a good approach to stop the mails from being sent to
> hotmail, that is why I ask here.
>
> What I have in mind is something like this:
>
> Make a powershell script that parses the logfile at intervals, and if it
> finds an smtp code 421 from hotmail, it will simply stop the smtp service on
> the server, I know that this means that mail to all other domains will be
> stopped also, but stopping mail to hotmail is top priority in this process,
> so a solution where the script stops the outgoing queue or enables a filter
> to stop outgoing mail to hotmail would be better but I dont know if thats
> easier/possible.
>
> However, I am not skilled enough to make this script without help - and I
> dont even know if this is a usable solution. So if anyone can give me some
> tips, a script that can do some or all of what I am looking for I would be
> very grateful!
>
> I know this is not an Exchange forum, but if someone knows about Exchange
> and knows of a better way to solve this, I am also very interested in
> learning more about it.

My System SpecsSystem Spec
Old 07-18-2007   #6 (permalink)
Rob Campbell


 
 

Re: Stop the smtp service on an Exchange 2007 server?

The "filter" would be a regex to match the event in the log. I don't know if
you could do this as a "transport rule" or not.

"Marco Shaw" wrote:

> Rob Campbell wrote:
> > First thing to do is find and example of a log entry of a connection to
> > hotmail that resulted in a 421. Once you have that you can start writing
> > your filter.

>
> The "filter" would be a "transport rule"?
>
> Marco
>

My System SpecsSystem Spec
Old 07-18-2007   #7 (permalink)
Rob Campbell


 
 

RE: Stop the smtp service on an Exchange 2007 server?

As far as stopping the emails, there are probably a number of ways to do
this. Basically all you have to do is screw up the server's ability to reach
hotmail's servers for awhile. Adding entries to the hosts file so it can't
resolve the host names properly, or an entry to the route table so that any
packets going that direction get blackholed would do it without stopping
delivery to anyone else.

"SuneR" wrote:

> That is true, and that is what I am planning to do.
>
> Maybe I fail to explain myself, but I am more interested in where and how I
> can make this filter. Exactly how the filter should get triggered is for me
> to figure out, by looking at the log file. But I am rather clueless as to how
> to stop the mails form being sent after my filter is triggered.
>
> Right now Im thinking that a scheduled job that read the log every 5 minutes
> is the way to go, but as I wrote below, this is all very new to me, so there
> might be a better and cleaner way to do it.
>
> I know the
>
> "Rob Campbell" wrote:
>
> > First thing to do is find and example of a log entry of a connection to
> > hotmail that resulted in a 421. Once you have that you can start writing
> > your filter.
> >
> > "SuneR" wrote:
> >
> > > We are in the process of getting a good mail reputation with hotmail.com, and
> > > hotmail.com wants us to stop sending them mail if they send us a 421 smtp
> > > code. That means we reached the limit, and that we should stop further
> > > sending to avoid getting a negative rep for that delivery.
> > >
> > > I am already looking into a solution with rules on an Exchange 2007 Edge
> > > Transport server, but so far no luck. But because I figure that no matter
> > > what, Powershell is a good approach to stop the mails from being sent to
> > > hotmail, that is why I ask here.
> > >
> > > What I have in mind is something like this:
> > >
> > > Make a powershell script that parses the logfile at intervals, and if it
> > > finds an smtp code 421 from hotmail, it will simply stop the smtp service on
> > > the server, I know that this means that mail to all other domains will be
> > > stopped also, but stopping mail to hotmail is top priority in this process,
> > > so a solution where the script stops the outgoing queue or enables a filter
> > > to stop outgoing mail to hotmail would be better but I dont know if thats
> > > easier/possible.
> > >
> > > However, I am not skilled enough to make this script without help - and I
> > > dont even know if this is a usable solution. So if anyone can give me some
> > > tips, a script that can do some or all of what I am looking for I would be
> > > very grateful!
> > >
> > > I know this is not an Exchange forum, but if someone knows about Exchange
> > > and knows of a better way to solve this, I am also very interested in
> > > learning more about it.

My System SpecsSystem Spec
Old 07-18-2007   #8 (permalink)
Marco Shaw


 
 

Re: Stop the smtp service on an Exchange 2007 server?


> What I have in mind is something like this:
>
> Make a powershell script that parses the logfile at intervals, and if it
> finds an smtp code 421 from hotmail, it will simply stop the smtp service on
> the server, I know that this means that mail to all other domains will be
> stopped also, but stopping mail to hotmail is top priority in this process,
> so a solution where the script stops the outgoing queue or enables a filter
> to stop outgoing mail to hotmail would be better but I dont know if thats
> easier/possible.


OK, I don't know where the SMTP code gets stored (get-eventlog,
get-messagetrackinglog)?

I did try this (formatting broken):
set-TransportRule -Name 'hotmail' -Comments '' -Conditions
'Microsoft.Exchange.MessagingPolicies.Rules.Tasks.SentToScopePredicate','Microsoft.Exchange.MessagingPolicies.Rules.Tasks.HeaderContainsPredicate'
-Actions
'Microsoft.Exchange.MessagingPolicies.Rules.Tasks.RejectMessageAction'
-Exceptions -Identity 'hotmail'

What this does is if I try to send something to an address that has
"hotmail" in the to field (might need to make it more specifice like
@hotmail.com), the message is rejected and a bounce back occurs.

That's 1/2 of the solution...

I love PowerShell!

Marco


My System SpecsSystem Spec
Old 07-18-2007   #9 (permalink)
Rob Campbell


 
 

Re: Stop the smtp service on an Exchange 2007 server?

I think this is going to have to come from the smtp service log to find the
421 RC.
I believe the objective is not to bounce the email, but to defer any
delivery attempts for some period of time once a connection results in a 421,
not just for that email but for any email to that domain.

"Marco Shaw" wrote:

>
> > What I have in mind is something like this:
> >
> > Make a powershell script that parses the logfile at intervals, and if it
> > finds an smtp code 421 from hotmail, it will simply stop the smtp service on
> > the server, I know that this means that mail to all other domains will be
> > stopped also, but stopping mail to hotmail is top priority in this process,
> > so a solution where the script stops the outgoing queue or enables a filter
> > to stop outgoing mail to hotmail would be better but I dont know if thats
> > easier/possible.

>
> OK, I don't know where the SMTP code gets stored (get-eventlog,
> get-messagetrackinglog)?
>
> I did try this (formatting broken):
> set-TransportRule -Name 'hotmail' -Comments '' -Conditions
> 'Microsoft.Exchange.MessagingPolicies.Rules.Tasks.SentToScopePredicate','Microsoft.Exchange.MessagingPolicies.Rules.Tasks.HeaderContainsPredicate'
> -Actions
> 'Microsoft.Exchange.MessagingPolicies.Rules.Tasks.RejectMessageAction'
> -Exceptions -Identity 'hotmail'
>
> What this does is if I try to send something to an address that has
> "hotmail" in the to field (might need to make it more specifice like
> @hotmail.com), the message is rejected and a bounce back occurs.
>
> That's 1/2 of the solution...
>
> I love PowerShell!
>
> Marco
>
>
>

My System SpecsSystem Spec
Old 07-19-2007   #10 (permalink)
SuneR


 
 

Re: Stop the smtp service on an Exchange 2007 server?

"Rob Campbell" wrote:

> I think this is going to have to come from the smtp service log to find the
> 421 RC.
> I believe the objective is not to bounce the email, but to defer any
> delivery attempts for some period of time once a connection results in a 421,
> not just for that email but for any email to that domain.


This is exactly what I am trying to do. But with Marcos script below, I
might be able to make something work. :-)
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Set new primary SMTP-addresses in Exchange 2007 PowerShell
outlook 2007 and ms exchange server Vista performance & maintenance
Exchange 2007 Administration through 32-bit windows service. PowerShell
Microsoft Releases Public Betas of Exchange Server 2007 and Forefront Security for Exchange Server Vista News
Microsoft Releases Public Betas of Exchange Server 2007 and Forefront Security for Exchange Server Vista News


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46