Gnus development mailing list
 help / color / mirror / Atom feed
From: Bruno Tavernier <tavernier.bruno@gmail.com>
To: gnus <ding@gnus.org>
Cc: Robert Pluim <rpluim@gmail.com>
Subject: Re: Multiple SMTP servers with Gnus?
Date: Wed, 09 Feb 2011 21:17:50 +0100	[thread overview]
Message-ID: <87k4h99d3l.fsf@gmail.com> (raw)
In-Reply-To: <pknlj1pyunq.fsf@this.is.really.invalid> (Robert Pluim's message of "Wed, 09 Feb 2011 18:39:21 +0100")

Hello Robert,

Robert Pluim <rpluim@gmail.com> writes:

> I currently have one SMTP server I talk to with Gnus, and another
> account with a web-mail interface that also supports SMTP. I'm
> considering just using Gnus for both, but I was wondering what the
> canonical method was for configuring this? gnus-posting-styles would
> theoretically fit, but I can't see any way to set any of the smtpmail
> variables in a posting style.

I wrote this simple piece of elisp code to automatically choose the smtp
parameters depending on the content (regexp) in the From header.

It works flawlessly so far. :-)

; ===== AUTO SMTP =====

; Use smtp with gnus/message
(setq message-send-mail-function 'smtpmail-send-it)

(defun my-message-send-smtp ()
  "Automatically adjust the stmp parameters to match the From header."
  (interactive)
  (cond 
   ; GMAIL
   ((string-match "gmail" (message-field-value "From"))
    ; SMTP address and port
    (setq smtpmail-smtp-server "smtp.gmail.com")
    (setq smtpmail-smtp-service 587)
    ; Secured connection
    (setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))))
   ; MY WORK PLACE
   ((string-match "mycompany" (message-field-value "From"))
    ; SMTP address and port
    (setq smtpmail-smtp-server "mail.mycompany")
    (setq smtpmail-smtp-service 25))
   ))

(add-hook 'message-send-hook 'my-message-send-smtp)

; ===== END =====

-- 
Bruno



  parent reply	other threads:[~2011-02-09 20:17 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-09 17:39 Robert Pluim
2011-02-09 17:46 ` Richard Riley
2011-02-09 18:06   ` Wes Hardaker
2011-02-09 18:48     ` Richard Riley
2011-02-09 22:23       ` Wes Hardaker
2011-02-09 23:27         ` Richard Riley
2011-02-09 20:17 ` Bruno Tavernier [this message]
2011-02-11 21:28   ` Robert Pluim
2011-02-14  2:25   ` Lars Ingebrigtsen
2011-02-14  7:45     ` David Edmondson
2011-02-14  8:34       ` Robert Pluim
2011-02-14  9:42     ` David Engster
2011-02-14 11:26       ` Richard Riley
2011-02-14 20:09         ` Lars Ingebrigtsen
2011-02-14 20:13           ` Lars Ingebrigtsen
2011-02-14 21:08             ` Ted Zlatanov
2011-02-14 21:23               ` Lars Ingebrigtsen
2011-02-16 16:12         ` Johnny
2011-02-16 16:28           ` Ted Zlatanov
2011-02-16 16:45             ` Johnny
2011-02-16 19:06               ` Ted Zlatanov
2011-02-16 20:41                 ` Johnny
2011-02-16 23:17                 ` Leo
2011-02-17 17:04                   ` Ted Zlatanov
2011-02-17 20:33                     ` Broken split-fancy upon updating gnus (Re: Multiple SMTP servers with Gnus?) Johnny
2011-02-17 22:38                       ` Lars Ingebrigtsen
2011-02-18 20:27                       ` Ted Zlatanov
2011-02-18 23:09                         ` Lars Ingebrigtsen
2011-02-21 20:25                           ` Ted Zlatanov
2011-02-19 10:54                         ` Johnny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k4h99d3l.fsf@gmail.com \
    --to=tavernier.bruno@gmail.com \
    --cc=ding@gnus.org \
    --cc=rpluim@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).