An AppleScript to switch Mail's SMTP servers

Jan 20, '03 09:46:27AM

Contributed by: Anonymous

Here is an Apple Script that will let you change your SMTP servers depending on your location. As you might have guessed from the examples below I am forced to use my ISP's SMTP server when I am at home.

on run
set myResult to display dialog "Where are you?"¬
buttons {"Home", "Work"}
tell application "Mail"
if the button returned of myResult is "Work" then
set smtp server of account "Work Email" to ¬
smtp server "mail.work.com"
set smtp server of account "Home Email" to¬
smtp server "mail.home.net"
else
set smtp server of account "Work Email" to ¬
smtp server "mail.isp.com"
set smtp server of account "Home Email" to ¬
smtp server "mail.isp.com"
end if
end tell
end run
[Editor's note: I have not tested this myself.]

Comments (14)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030120064627834