change mail settings for a ssh tunnel (LocalForward)

Do No Use This
I’ve noticed that when i run the script occasionally it loses all messages from the inbox and the sent box.

Ok the other day i was using ssh’s dynamicForward option combined with the system socks proxy setting on localhost (this should tunnel all traffic through the ssh tunnel and work out the appropriate protocol on the other end.) The only application that i’ve found that doesn’t like this is

After some searching i found that others have been complaining about this since 10.1 . This is really quite poor on apples behalf. So the only way i could think of arround this was to use the localForward. but this means that when you want to tunnel it you will have to go into mail and change the ports and server names and so forth.

so i came up with this function / script to make this very simple.

on accountModify(accName, ServerName, incomingPort, sslOn, smtpString)
	tell application "Mail"
		tell account accName
			set server name to ServerName
			set port to incomingPort
			set uses ssl to sslOn
		end tell
		set smtp server of account accName to smtp server smtpString
	end tell
end accountModify

set buttonTunnel to "Tunnel"
set buttonNormal to "Normal"
set result to display dialog "What settings would you like to user with mail" buttons {buttonTunnel, buttonNormal}
set theButton to button returned of result

if theButton is equal to buttonTunnel then
	-- set the servers to localhost and change ports
	accountModify("accountName", "localhost", 1110, false, "localhost:user")
	-- set it back to default
	accountModify("accountName", "mail.", 995, true, "mail.")
end if

and my ~/.ssh/config file looks like this
Host myMacMini
User kim
Port 12222
IdentityFile ~/.ssh/id_mini
LocalForward 1110
LocalForward 25555 mail.

so now all i do is:
open terminal and type " ssh myMacMini "
run my script and click tunnel

and all my mail is securly running through to my home then to myisp.

and when i’m done i just run my script again and click normal and everything is normal again

This is fixed in 10.4.7 so my script was a waste of time, maybe no one else complained to apple about this just wrote about it in their blogs and thought apple should find it and fix it.