[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to enable SMTP "profile switching"?

From: Tom Roche
Subject: how to enable SMTP "profile switching"?
Date: Tue, 16 Aug 2011 20:33:08 -0400
User-agent: GNU Emacs 23.3.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.4)

summary: To send email, I currently use smtpmail mostly with a single
SMTP "profile" (i.e. tuple of SMTP server name, port number, account
name, etc). Soon I will need to regularly switch between 2 such
profiles. I currently switch by

* editing a file
* byte-compile-file
* restarting emacs

Is there an easier/quicker way to do this? Should I be using different
tools entirely?


I'm using

GNU Emacs 23.3.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.4)
 of 2011-04-10 on brahms, modified by Debian


$ lsb_release -ds
Linux Mint Debian Edition
$ uname -rv
2.6.39-2-amd64 #1 SMP Tue Jul 5 02:51:22 UTC 2011

I have a file name=tlrMail.el which I load from init.el. tlrMail does

(setq message-send-mail-function 'smtpmail-send-it)
(setq send-mail-function 'smtpmail-send-it)
(setq smtpmail-debug-info t)
(setq smtpmail-debug-verb t)
(setq starttls-use-gnutls t)
(setq starttls-gnutls-program "gnutls-cli")
(setq starttls-extra-arguments nil)

before setting variables related to what some mail clients (e.g.,
thunderbird) would call an profile: in my case those are SMTP server
name, SMTP server port number, account name, etc. After that, tlrMail

(require 'smtpmail)

This allows me to switch SMTP settings (for this example, from using
SMTP from to by doing

1 isearch-query-replace one region of tlrMail, e.g., s/foo/bar/g

- (setq smtpmail-local-domain foo-domain-name)
- (setq smtpmail-sendto-domain foo-domain-name)
- (setq smtpmail-smtp-server foo-smtp-server-hostname)
- (setq smtpmail-smtp-service foo-smtp-server-port)
- (setq user-mail-address foo-user-mail-address)
- (setq smtpmail-starttls-credentials foo-starttls-credentials)
+ (setq smtpmail-local-domain bar-domain-name)
+ (setq smtpmail-sendto-domain bar-domain-name)
+ (setq smtpmail-smtp-server bar-smtp-server-hostname)
+ (setq smtpmail-smtp-service bar-smtp-server-port)
+ (setq user-mail-address bar-user-mail-address)
+ (setq smtpmail-starttls-credentials bar-starttls-credentials)

  where the latter variables have been pre-defined.

2 byte-compile-file tlrMail.el

3 restart emacs

This has worked well for me, because I rarely had cause to switch. Now,
however, a workplace is insisting that everyone use their SMTP for
work-related purposes. Hence I will be switching much more often, so I'm
looking for a more performant solution. Is there an easier/quicker way
to do this? Should I be using different tools entirely? (Is this what's
finally gonna force me to learn Gnus ?-)

Feel free to reply directly to me as well as the list.
Your suggestions are appreciated, Tom Roche <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]