For Programmers: Free Programming Magazines  


Home > Archive > Tcl > April 2007 > Redirect all SMTP traffic to a specific server









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Redirect all SMTP traffic to a specific server
Fernando Quinones

2007-04-24, 10:06 pm

Group,

I have a need to forward all communication in port 25 to my default mail
server. I wonder if someone has written anything in tcl to do that. I'm
not sure how to start putting such code together and I need to get it
done before Friday or I will have to return the system I bought.
Anyone knows of such code or can direct me to some resource that can
help me in the building of this program. I'm sorry I'm so rush,
generally when I come here I just have a simple question or a code that
is not doing what I want but I am kinda lost here and very short of time.

If you care to know why I need that, here is the reason:

I have a security program that emails me when certain zones are alarmed.
The system uses my desktop computer running Windows XP home to send the
email. It actually creates an smtp server in the desktop pc and sends
the email that way. I have the system working perfectly in a commercial
adsl line. The problem is that I need to have this running in a
residential line. Both lines are provided by Bellsouth. It is BellSouth
policy to only allow communication to their smpt server in port 25, so
everything else gets blocked.
This security software is not too robust and does not allow me to select
either port of a different smtp server. At least that is what their
“technical support” says.

Right now I can’t change to a different security system or change ISP
provider.

Thanks!
slebetman@yahoo.com

2007-04-26, 4:16 am

On Apr 24, 10:51 pm, Fernando Quinones <fernan...@bellsouth.net>
wrote:
> policy to only allow communication to their smpt server in port 25, so
> everything else gets blocked.
> This security software is not too robust and does not allow me to select
> either port of a different smtp server. At least that is what their
> "technical support" says.
>


Sorry if this is a multiple post. goolgle seem to be having problems
again.

So you want to send out SMTP to ports other than 25 right? This of
course can be done by the OS itself using NAPT without resorting to
tcl. That is, if your OS is unix based. I don't know how to do it in
windows so here's a simple Tcl redirector:

# Configuration parameters:
array set source {
port 25
}

array set destination {
host custom.mailserver.mydomain.com
port 8080
}

# Event handlers:
proc transfer {in out} {
set data [read $in]
if {[eof $in]} {
close $in
close $out
return
}
puts -nonewline $out $data
flush $out
}

proc proxify {channel caddr cport} {
global source destination

if {[catch [list socket $destination(host) $destination(port)] f]}
{
close $channel
error $f
}

foreach sock [list $channel $f] {
fconfigure $sock -blocking 0 -translation binary
}

fileevent $channel readable [list transfer $channel $f]
fileevent $f readable [list transfer $f $channel]
}

socket -server porxify $source(port)

if {[catch {winfo x .}]} {
# if we reach here then we're running in tclsh
vwait forever
}

Fernando Quinones

2007-04-26, 7:08 pm

slebetman@yahoo.com wrote:
> On Apr 24, 10:51 pm, Fernando Quinones <fernan...@bellsouth.net>
> wrote:
>
> Sorry if this is a multiple post. goolgle seem to be having problems
> again.
>
> So you want to send out SMTP to ports other than 25 right? This of
> course can be done by the OS itself using NAPT without resorting to
> tcl. That is, if your OS is unix based. I don't know how to do it in
> windows so here's a simple Tcl redirector:
>
> # Configuration parameters:
> array set source {
> port 25
> }
>
> array set destination {
> host custom.mailserver.mydomain.com
> port 8080
> }
>
> # Event handlers:
> proc transfer {in out} {
> set data [read $in]
> if {[eof $in]} {
> close $in
> close $out
> return
> }
> puts -nonewline $out $data
> flush $out
> }
>
> proc proxify {channel caddr cport} {
> global source destination
>
> if {[catch [list socket $destination(host) $destination(port)] f]}
> {
> close $channel
> error $f
> }
>
> foreach sock [list $channel $f] {
> fconfigure $sock -blocking 0 -translation binary
> }
>
> fileevent $channel readable [list transfer $channel $f]
> fileevent $f readable [list transfer $f $channel]
> }
>
> socket -server porxify $source(port)
>
> if {[catch {winfo x .}]} {
> # if we reach here then we're running in tclsh
> vwait forever
> }
>


Thanks for your response!!! My English is not helping me much! LOL! You
are close to what I want to do.
It is windows xp, I run multiple tcl programs using the tcl versions for
windows then generally use freewrap if I need to wrap the application to
share it with a friend.
Anyway, I want to trap or capture all smtp communications leaving my pc.
Everything in port 25. Then I want to process that information to be
able to send that to my isp provider server for delivery.
If this could be tied to a specific program it will work even better. I
have that security program and it tries itself to contact my blackberry
and yahoo mail servers to deliver the mail and as I stated before my isp
dont allow that. So if i can capture the delivery attempt, format it so
it can be send to my isp I would not have a problem.

Thanks!
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com