From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Roche Newsgroups: gmane.emacs.help Subject: Re: extract smtpmail data from .authinfo (or .authinfo.gpg)? Date: Fri, 26 Aug 2011 18:40:26 -0400 Message-ID: <87mxevhk4l.fsf@pobox.com> References: <87d3frx23d.fsf@pobox.com> <87aaavrg9q.fsf@pobox.com> <877h6b29vr.fsf@matica.localdomain> <87vctwg13y.fsf@gmail.com> <87liusrh3h.fsf@pobox.com> <87aab80yuz.fsf@pobox.com> Reply-To: help-gnu-emacs@gnu.org, Tom Roche NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1314398443 11622 80.91.229.12 (26 Aug 2011 22:40:43 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 26 Aug 2011 22:40:43 +0000 (UTC) To: help-gnu-emacs@gnu.org, Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 27 00:40:38 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Qx54l-00064w-7u for geh-help-gnu-emacs@m.gmane.org; Sat, 27 Aug 2011 00:40:35 +0200 Original-Received: from localhost ([::1]:42305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qx54j-0006CG-Pb for geh-help-gnu-emacs@m.gmane.org; Fri, 26 Aug 2011 18:40:33 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:56677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qx54d-00069V-DH for help-gnu-emacs@gnu.org; Fri, 26 Aug 2011 18:40:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qx54b-0005Kn-Dj for help-gnu-emacs@gnu.org; Fri, 26 Aug 2011 18:40:27 -0400 Original-Received: from b-pb-sasl-quonix.pobox.com ([208.72.237.35]:49297 helo=smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qx54b-0005Kj-5Q for help-gnu-emacs@gnu.org; Fri, 26 Aug 2011 18:40:25 -0400 Original-Received: from smtp.pobox.com (unknown [127.0.0.1]) by b-sasl-quonix.pobox.com (Postfix) with ESMTP id 66CB844BE; Fri, 26 Aug 2011 18:40:23 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:in-reply-to:references:reply-to:date:message-id :mime-version:content-type; s=sasl; bh=MyJ/Nc70gUH+LHAxLusziqF8p ZE=; b=TAi/k6vDcvXBOePFcSvboA9WUD0uHMYEwHWZYGWDoy75IGh+psXsVD/ks WJtJn/G7mcVeC508nLjJ6o5C1KgDLmaYFTBtZT8K9pMIL+AWnYGD2u7kDn5RYSLW j45XeP3V725nFeOUtIyFunb7mIvdcMC1YH8Y8PphndTNpHYN+Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :in-reply-to:references:reply-to:date:message-id:mime-version :content-type; q=dns; s=sasl; b=cGrqyRidoQLTyj300Wtly2P++4LzsCOJ r0a76tdHMrRC3WoMFskCJyIQFq2SCdeGkQR0Fl8ptbwtIzboHtzvOd+8PAIQwWRj 4XbMlh41Y79bXbmUF9Odj5LdP+m00Y37p1MzBeM2ROLFTiTAhasTD8lW3/7y9fzM +qbDwPwtzTQ= Original-Received: from b-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by b-sasl-quonix.pobox.com (Postfix) with ESMTP id 5EBE744BD; Fri, 26 Aug 2011 18:40:23 -0400 (EDT) Original-Received: from tlrPanP5.pobox.com (unknown [75.177.137.62]) by b-sasl-quonix.pobox.com (Postfix) with ESMTPA id B632444BA; Fri, 26 Aug 2011 18:40:22 -0400 (EDT) In-Reply-To: <877h6b29vr.fsf@matica.localdomain> User-Agent: GNU Emacs 23.3.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.4) X-Pobox-Relay-ID: 627EEFD4-D034-11E0-8556-1DC62E706CDE-07218935!b-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 208.72.237.35 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:82076 Archived-At: Tom Roche Wed, Aug 17, 2011 at 12:47 PM >> * Does smtpmail have some mechanism to extract server name, port#, >> etc from .authinfo*. Alternatively, how to elisp read-and-extract? pcode like get_connection_data(filename=~/.authinfo, servername) connection_string=line containing servername in filename from connection_string, parse pairs for machine, login, port, etc return pairs except for machine (which we already know) >> (Unfortunately my elisp is pretty weak, so any assistance is >> appreciated.) Ian Zimmerman Wed, 17 Aug 2011 11:03:36 -0700 > I don't understand; that is what smtpmail does by default. Not mine--more below. > Here's my .authinfo, massaged for public consumption: > machine my.linode.server login itz password s3kri7 port 993 > machine my.linode.server login itz password s3kri7 port 587 That's very similar to mine, but I don't currently have passwords in massaged .authinfo > machine smtp.foo.com login me port 26 > machine smtp.bar.com login me port 587 So I don't think the problem is in my .authinfo, but in my code (or smtpmail.el, but I guess bugs in that would've been caught already). myMail.el gets called from my init.el: massaged working myMail.el + ;;; mail-related elisp------------------------------------------------ + (setq user-full-name "Me Me Me") + (setq message-send-mail-function 'smtpmail-send-it) + ;;; throw this in, anyway + (setq send-mail-function 'smtpmail-send-it) + ;;; debugging==t + (setq smtpmail-debug-info t) ; only this is necessary? + (setq smtpmail-debug-verb t) + (setq smtpmail-auth-credentials (expand-file-name "~/.authinfo")) + ; following could all be gotten from ~/.authinfo? or ~/.authinfo.gpg? + ;;; using foo.com--------------------------------------------------- + (setq foo-smtp-server-port 26) ; evil blocks 25 + (setq foo-domain-name "foo.com") + (setq foo-smtp-server-hostname "smtp.foo.com") + (setq foo-user-mail-id "me") + (setq foo-user-mail-name "Me_Me") + (setq foo-user-mail-address (concat foo-user-mail-name "@" foo-domain-name)) + (setq foo-starttls-credentials + (list (list foo-smtp-server-hostname foo-smtp-server-port 'nil 'nil) )) + ;;; using bar.com------------------------------------------------ + (setq bar-domain-name "bar.com") + (setq bar-smtp-server-hostname "smtp.bar.com") + (setq bar-smtp-server-port 587) + (setq bar-user-mail-id "me") + (setq bar-user-mail-address (concat bar-user-mail-id "@" bar-domain-name)) + (setq bar-starttls-credentials + (list (list bar-smtp-server-hostname bar-smtp-server-port 'nil 'nil) )) + ;;; using whatever---------------------------------------------------- + ;;; s/foo/bar/g or vv + (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-id foo-user-mail-id) + (setq user-mail-address foo-user-mail-address) + ;;; TLS--------------------------------------------------------------- + (setq starttls-use-gnutls t) + (setq starttls-gnutls-program "gnutls-cli") + (setq starttls-extra-arguments nil) + ;;; load libraries---------------------------------------------------- + ;; after setting variables above + (require 'smtpmail) + ;; (require 'starttls) ; apparently unnecessary This works (i.e., mail gets sent), except that - I'm explicitly setting connection data ('user-mail-id', 'smtpmail-smtp-service'), which I would like to lookup from .authinfo (given 'smtpmail-smtp-server' as "primary key") - I can only switch between SMTP servers by editing myMail.el and byte-compile-file, but that's the topic of another thread (namely http://lists.gnu.org/archive/html/help-gnu-emacs/2011-08/msg00111.html ) So what happens if I comment-out the other data? With my .authinfo unchanged, and me@it:~$ diff -u ~/.emacs.d/myMail.el_good ~/.emacs.d/myMail.el ... -(setq smtpmail-smtp-service pobox-smtp-server-port) -(setq user-mail-id pobox-user-mail-id) +; (setq smtpmail-smtp-service pobox-smtp-server-port) +; (setq user-mail-id pobox-user-mail-id) after I - `M-x byte-compile-file ~/.emacs.d/myMail.el` - restart emacs - try to send mail I get *Backtrace* > Debugger entered--Lisp error: (error "Sending failed; SMTP protocol error") > signal(error ("Sending failed; SMTP protocol error")) > error("Sending failed; SMTP protocol error") > smtpmail-send-it() > message-send-mail(nil) > message-send-via-mail(nil) > message-send(nil) > message-send-and-exit(nil) > call-interactively(message-send-and-exit nil nil) and no mail. But if I + `cp ~/.emacs.d/myMail.el_good ~/.emacs.d/myMail.el` + `M-x byte-compile-file ~/.emacs.d/myMail.el` + restart emacs I can again send mail. So my question is, how to get my code to read the port and id from .authinfo, given the hostname? TIA, Tom Roche