From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/76545 Path: news.gmane.org!not-for-mail From: Richard Riley Newsgroups: gmane.emacs.gnus.general Subject: Re: smtp credential, multiple smtp, posting styles and smtpmail Date: Thu, 10 Feb 2011 12:58:56 +0100 Organization: aich tea tea pea dicky riley dot net Message-ID: <2pmxm4drz6.fsf@news.eternal-september.org> References: <87ipwsw8j9.fsf@keller.adm.naquadah.org> <87ipws86pn.fsf@netarch.haselwarter.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1297339191 24782 80.91.229.12 (10 Feb 2011 11:59:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 10 Feb 2011 11:59:51 +0000 (UTC) Cc: ding@gnus.org To: Philipp Haselwarter Original-X-From: ding-owner+M24892@lists.math.uh.edu Thu Feb 10 12:59:47 2011 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PnVBS-00084o-12 for ding-account@gmane.org; Thu, 10 Feb 2011 12:59:38 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1PnVBB-0000fQ-CY; Thu, 10 Feb 2011 05:59:21 -0600 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1PnVB9-0000fB-TK for ding@lists.math.uh.edu; Thu, 10 Feb 2011 05:59:19 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1PnVB7-0004WF-79 for ding@lists.math.uh.edu; Thu, 10 Feb 2011 05:59:19 -0600 Original-Received: from mail-bw0-f44.google.com ([209.85.214.44]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1PnVB6-0001Bv-0K for ding@gnus.org; Thu, 10 Feb 2011 12:59:16 +0100 Original-Received: by bwz12 with SMTP id 12so1897859bwz.17 for ; Thu, 10 Feb 2011 03:59:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:in-reply-to:date :organization:message-id:references:user-agent:mime-version :content-type; bh=chgwUn9kJjiAbIQWwWlqx7TG9jnaQkqKpMdqNmQmkYg=; b=kCksM8pPzXShf+KHBItgq6tG9uRUc1aVJunuC753wNU42SeolEIEVvfzmkAYvfeAu/ dKfY5lU3QncBtOKlr4Pir1n0Dwp+Z9+ooY1/xtpH+/42fN8U5qLF8s1FZcLMqkNrtJGA UYO/S7smsYml9uEDOO1WeiMHVxtxUroSV/51E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:subject:in-reply-to:date:organization:message-id :references:user-agent:mime-version:content-type; b=j18J4OdusxT1G5wn4K936L6JBXs8rQ4PEQxHCyDoUwvLiOCLomXrWaLlxPaW/F/ezm FGBZMePek3/ZlWrzT9eve7A8aYy2Tp29DZxZ+wq1FaV9bRDQ8CfjiMqJLypB2jENNX2V hQBv/P2iVIgO61czNc3F+gfJKPKiOWTqldW4c= Original-Received: by 10.204.24.9 with SMTP id t9mr3083645bkb.183.1297339148946; Thu, 10 Feb 2011 03:59:08 -0800 (PST) Original-Received: from localhost ([85.183.18.158]) by mx.google.com with ESMTPS id j11sm925575bka.0.2011.02.10.03.59.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 10 Feb 2011 03:59:08 -0800 (PST) In-Reply-To: <87ipws86pn.fsf@netarch.haselwarter.org> (Philipp Haselwarter's message of "Thu, 10 Feb 2011 12:33:24 +0100") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) X-Spam-Score: -3.0 (---) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:76545 Archived-At: Philipp Haselwarter writes: > My config is using the code from emacswiki. I set my identities with > posting styles, smtp parameters get set on sending. Works flawlessly, > with no dependency on external programs. > > > > (defun set-smtp (mech server port user password) > "Set related SMTP variables for supplied parameters." > (setq smtpmail-smtp-server server > smtpmail-smtp-service port > smtpmail-auth-credentials (list (list server port user password)) > smtpmail-auth-supported (list mech) > smtpmail-starttls-credentials nil) > (message "Setting SMTP server to `%s:%s' for user `%s'." > server port user)) > > (defun set-smtp-ssl (server port user password &optional key cert) > "Set related SMTP and SSL variables for supplied parameters." > (setq starttls-use-gnutls t > starttls-gnutls-program "gnutls-cli" > ;; TODO: Add this to the server parameters > ;; starttls-extra-arguments nil > smtpmail-smtp-server server > smtpmail-smtp-service port > smtpmail-auth-credentials (list (list server port user password)) > smtpmail-starttls-credentials (list (list server port key cert))) > (message > "Setting SMTP server to `%s:%s' for user `%s'. (SSL enabled.)" > server port user)) > > (defun change-smtp () > "Change the SMTP server according to the current from line." > (interactive) > (save-excursion > (loop with from = (save-restriction > (message-narrow-to-headers) > (message-fetch-field "from")) > for (auth-mech address . auth-spec) in smtp-accounts > when (string-match address from) > do (cond > ((memq auth-mech '(cram-md5 plain login)) > (return (apply 'set-smtp (cons auth-mech auth-spec)))) > ((eql auth-mech 'ssl) > (return (apply 'set-smtp-ssl auth-spec))) > (t (error "Unrecognized SMTP auth. mechanism: `%s'." auth-mech))) > finally (error "Cannot infer SMTP information.")))) > > (add-hook 'message-send-hook 'change-smtp) > > (setq smtp-accounts '((ssl "philipp.haselwarter@gmx.de" > "localhost" "2025" > "philipp" nil) > (ssl "philipp.haselwarter@etu.upmc.fr" "courriel.upmc.fr" "587" > "29....." nil) > (ssl "me@gmail.com" "smtp.gmail.com" "587" > "me@gmail.com" nil))) > > > (setq gnus-posting-styles > '((".*" > (name "Philipp Haselwarter") > (address "philipp.haselwarter@gmx.de") > (body "\n\n") > (signature-file "~/.signature")) > ("University" > (name "Philipp Haselwarter") > (address "philipp.haselwarter@etu.upmc.fr")))) > > > > I have a gnus startup hook that opens a ssh tunnel to my mailserver on > port 443 which allows me to read/send mail from behind firewalls, thus > localhost as primary smtp server. Yes, this is similar but superior to what I posted yesterday and uses a switch to change the smtp server at message send time based on the address which in turn is set in the gnus posting style. It was this posting that got me thinking that I ought to be able to set all I need in the posting style and not need to call the change smtp function or equivalent. Since I cant see your .authinfo.gpg, I am assuming it contains names where the machine names match the second element in the smtp list elements? This is certainly cleaner than using msmtp and so I'll give it a go - thanks! Its certainly more comprehensive with the auth mechs being checked, side note : (I'm still wonder if I ought to be just be able to set smtpmail-auth-credentials in the gnus-posting-style and leave the sendmail program as smtp and it "just work" - or rather I cant see why it doesnt just work. e.g '(("smtp.gmail.com" 25 "rileyrg@googlemail.com" "*******")) in the posting style : then no change-smtp at send stuff is required and life is even simpler.)