From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/14340 Path: news.gmane.org!not-for-mail From: Richard Riley Newsgroups: gmane.emacs.gnus.user Subject: Re: Multiple sources and accounts with GNUS Date: Mon, 20 Dec 2010 17:42:25 +0100 Organization: aich tea tea pea dicky riley dot net Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1292866820 7605 80.91.229.12 (20 Dec 2010 17:40:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 20 Dec 2010 17:40:20 +0000 (UTC) To: info-gnus-english@gnu.org Original-X-From: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Mon Dec 20 18:40:14 2010 Return-path: Envelope-to: gegu-info-gnus-english@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PUjiW-0001tQ-I6 for gegu-info-gnus-english@m.gmane.org; Mon, 20 Dec 2010 18:40:12 +0100 Original-Received: from localhost ([127.0.0.1]:56360 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PUjiV-0005fV-Jx for gegu-info-gnus-english@m.gmane.org; Mon, 20 Dec 2010 12:40:11 -0500 Original-Path: usenet.stanford.edu!goblin3!goblin1!goblin.stu.neva.ru!uio.no!quimby.gnus.org!not-for-mail Original-Newsgroups: gnu.emacs.gnus Original-Lines: 55 Original-NNTP-Posting-Host: 85.183.18.158 Original-X-Trace: quimby.gnus.org 1292863345 16735 85.183.18.158 (20 Dec 2010 16:42:25 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Mon, 20 Dec 2010 16:42:25 +0000 (UTC) User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.gnus:85065 X-BeenThere: info-gnus-english@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader \(in English\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Errors-To: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.gnus.user:14340 Archived-At: Yuri D'Elia writes: > Hi everyone. After a long period with mutt (which indeed sucks less but > doesn't do news) and sylpheed/claws (which just sucks), I'm back to > GNUS. I'm a sadist underneath - I know. > > So far I was able to setup all the receiving accounts successfully (a > couple of nnimap accounts, gmane via nntp, nnmaildir for local spools, > etc), but I'm having trouble to send outgoing e-mails to different > accounts depending on the current group. > > I'm fine with the default of using sendmail, but for a couple of IMAP > groups I need to use a specific SMTP server with credentials. > > Could I use 'gnus-parameters' for that, and change > 'message-send-mail-function' depending on the group? Any pointer or > small example in how to do this? > > Thanks. > msmtp is your man. ,---- | ;; Select the correct smtp server based on the from address. | (defun msmtp-account (&optional def) | (let* ((from | (save-restriction | (message-narrow-to-headers) | (message-fetch-field "From"))) | (account (if from (catch 'match | (dolist (element msmtp-name-list) | ;; (message (format "smpt chosen is %s" element)) | (when (string-match (format ".*%s.*" element) from) | (throw 'match element)))) nil))) | (if account account (if def def "default")))) | | (defun msmtp-change-smtp () | (setq sendmail-program "/usr/bin/msmtp") | (setq smtpmail-starttls-credentials '(("smtp.googlemail.com" 587 nil nil))) | (setq smtpmail-smtp-server "smtp.googlemail.com") | (setq message-sendmail-envelope-from 'header) | (if (message-mail-p) | (setq message-sendmail-extra-arguments (list "-a" (msmtp-account "default"))))) | (add-hook 'message-send-hook 'msmtp-change-smtp) `---- My code above selects the msmtp profile to use based on the From address which, im turn, is set by gnus-posting-styles but hopefully you can adjust as appropriate. Googling up the key vars above and msmtp should provide the info you need.