2008 / SSID-based SMTP server changer for
Evolution
SSID-based SMTP server changer for Evolution
This is a simple Python script that utilizes gconf and
NetworkManager (via D-Bus) to check which wireless network (SSID) you
are currently connected to, and updates Evolution's accounts list (in
gconf) to point to the correct SMTP server for that network.
This should come in handy when you roam between two (or more) wireless
networks and these networks are connected to different ISPs. In my
case, these are
aon and
Silver Server, and sending e-mail from
each network only works when the ISP-specific SMTP server is configured
in the sending e-mail settings for each account.
On Maemo, we already have this setting (you can specify the
SMTP server based on the SSID of the wireless network, and the Internet
Tablet knows how to send E-Mails). I've filed a bug report (Bug 510909:
Default SMTP server based on NetworkManager SSID) against Evolution
in Gnome's bug tracker, but got no reaction so far.
Usage
You can start the script by running
python evolution-smtp.py,
but you probably want to configure it first. You should run
python
evolution-smtp.py --identify to show the current SSID and SMTP
server, and you can copy the given line directly to the script, i.e.
into the
MY_NETWORKS dict. Don't forget to remove the
examples in the script ;)
When you are at another location, set the correct SMTP
settings in Evolution and re-run the "identify" command to give you the
correct line for this network, and also add it to the dict. After you
have set up all your networks and SMTP servers this way, you simply run
the script (python evolution-smtp.py) and it will check if
the SMTP server settings need to be updated and give you a (hopefully)
clear notification what has been done or what went wrong :) If the
variable RUN_AS_DAEMON is set to True,
evolution-smtp will continue to run in the background and will re-run
whenever NetworkManager's interface status changes.
What works
- Specifying an SMTP server (+advanced settings, like SSL,
TLS, etc..) per SSID
- Specifying a fallback SMTP server when not connected to
wireless (i.e. wired)
- Running as background process/daemon, watching for network
and account changes
What doesn't work
- No GUI to configure (have to use "--identify" and add
SMTP/SSID pairs to script)
- Specifying which accounts to update the SMTP server for
(currently, all are updated)
- Changin SMTP server based on wired network properties (i.e.
assigned IP, etc..)
Download
License
- BSD-style (see the source file)
Dependencies
- python (tested w/ Python 2.5)
- python-gconf
- python-gobject
- python-dbus
- python-pynotify
- python-xml (or at least xml.dom.minidom)
- NetworkManager
- Evolution
Helpful links to library documentation
Thomas Perl (thp at this domain), jabber:
thp@jabber.org