Gnus development mailing list
 help / color / mirror / Atom feed
* smtp credential, multiple smtp, posting styles and smtpmail
@ 2011-02-10  9:03 Richard Riley
  2011-02-10  9:20 ` Julien Danjou
  2011-02-14  2:20 ` smtp credential, multiple smtp, posting styles and smtpmail Lars Ingebrigtsen
  0 siblings, 2 replies; 11+ messages in thread
From: Richard Riley @ 2011-02-10  9:03 UTC (permalink / raw)
  To: nognus


Does someone have a way of extracting/setting the correct credentials
for smtp posting based on the contents of .authinfo.gpg when using
gnus-posting-styles?

The problem with msmtp is that the data is in cleartext.

The issue with smtpmail-auth-credentials is that I dont think it can easily be used
with the "logical" machine name in the authinfo.gpg e.g

  (add-to-list 'gnus-secondary-select-methods '(nnimap "riley"
                                    (nnimap-address "imap.gmail.com")
                                    (nnimap-server-port 993)
                                    (nnimap-stream ssl)))

Here the authinfo "machine" is "riley". 

I'm guessing the best and easiest way is to put my gnus-posting-styles all in
a gpg file and hardcode the smtp server and id/password in them. Anyone
out there already done this? It certainly seems the easiest if
possible. I just need to try and figure out which gnus variables are
used.

Another solution, that might even exist, would be for a server select
method to have the associated outgoing smtp server name as a parameter
and assume the same access credentials as when reading mail on that
server. Again, can I already do this?

Ideally I'm trying to avoid juggling which smtp server based on using
"from" hacks from around the web and just set access data directly using
the gnus posting style.

Googling around leaves me a tad jaded - so many options and so complex
at times ;)



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: smtp credential, multiple smtp, posting styles and smtpmail
  2011-02-10  9:03 smtp credential, multiple smtp, posting styles and smtpmail Richard Riley
@ 2011-02-10  9:20 ` Julien Danjou
  2011-02-10  9:36   ` Richard Riley
       [not found]   ` <ygfd3n0nrpj.fsf_-_@vserv.viteno.net>
  2011-02-14  2:20 ` smtp credential, multiple smtp, posting styles and smtpmail Lars Ingebrigtsen
  1 sibling, 2 replies; 11+ messages in thread
From: Julien Danjou @ 2011-02-10  9:20 UTC (permalink / raw)
  To: Richard Riley; +Cc: nognus

[-- Attachment #1: Type: text/plain, Size: 397 bytes --]

On Thu, Feb 10 2011, Richard Riley wrote:

> Does someone have a way of extracting/setting the correct credentials
> for smtp posting based on the contents of .authinfo.gpg when using
> gnus-posting-styles?

You should not need that. smtp should use credentials based on
.authinfo.gpg using auth-source. Otherwise it's almost a bug. :)

-- 
Julien Danjou
❱ http://julien.danjou.info

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: smtp credential, multiple smtp, posting styles and smtpmail
  2011-02-10  9:20 ` Julien Danjou
@ 2011-02-10  9:36   ` Richard Riley
  2011-02-10 11:33     ` Philipp Haselwarter
       [not found]   ` <ygfd3n0nrpj.fsf_-_@vserv.viteno.net>
  1 sibling, 1 reply; 11+ messages in thread
From: Richard Riley @ 2011-02-10  9:36 UTC (permalink / raw)
  To: nognus

Julien Danjou <julien@danjou.info> writes:

> On Thu, Feb 10 2011, Richard Riley wrote:
>
>> Does someone have a way of extracting/setting the correct credentials
>> for smtp posting based on the contents of .authinfo.gpg when using
>> gnus-posting-styles?
>
> You should not need that. smtp should use credentials based on
> .authinfo.gpg using auth-source. Otherwise it's almost a bug. :)

But it is needed for multiple smtp servers. Hence all the "select smtp
server at message send" hacks.

I already use a gpg file (.authinfo.gpg) .

Also there is the issue, which I mentioned, of logical names used in
select methods - there is no smtp server or real server set in the
.authinfo file - its done in the select method.

e.g I thought something like this in my "secret.gpg"

,----
| (setq gnus-posting-styles `((".*"
|                                   (from "Richard Riley <rileyrg@googlemail.com>")
|                                   (eval(setq gnushush-user-agent-header (quote real)))
|                                   (signature-file "~/.emacs.d/.sigs/rgr.sig")
|                                   (eval (setq mml2015-signers '("AB23BE58")))
|                                   (eval (setq smtpmail-auth-credentials '(("smtp.gmail.com" 25 "rileyrg@googlemail.com" "******"))))
|                                   ;;(eval (setq message-sendmail-extra-arguments  '("-a" "riley")))
|                                   (organization "aich tea tea pea dicky riley dot net"))))
`----

note the setting of smtpmail-auth-credentials. (and the commented out
"extra args" previously used for msmtp)

Or? (Its quite possibly I'm doing the dying fly dance here ;))




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Your public key
       [not found]     ` <87y65ouqa5.fsf@keller.adm.naquadah.org>
@ 2011-02-10 11:21       ` Norbert Koch
  0 siblings, 0 replies; 11+ messages in thread
From: Norbert Koch @ 2011-02-10 11:21 UTC (permalink / raw)
  To: ding

* Julien Danjou <julien@danjou.info>:

> It's on pgp.mit.edu at least.

Thanks! Imported :-)
norbert.
-- 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: smtp credential, multiple smtp, posting styles and smtpmail
  2011-02-10  9:36   ` Richard Riley
@ 2011-02-10 11:33     ` Philipp Haselwarter
  2011-02-10 11:58       ` Richard Riley
  2011-02-10 23:15       ` Richard Riley
  0 siblings, 2 replies; 11+ messages in thread
From: Philipp Haselwarter @ 2011-02-10 11:33 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 181 bytes --]

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.


[-- Attachment #2: .emacs --]
[-- Type: application/emacs-lisp, Size: 1880 bytes --]

[-- Attachment #3: .gnus.el --]
[-- Type: application/emacs-lisp, Size: 713 bytes --]

[-- Attachment #4: .authinfo.gpg --]
[-- Type: application/octet-stream, Size: 128 bytes --]

machine courriel.upmc.fr login 29..... password password1 port 587
machine localhost login philipp password password2 port 2025

[-- Attachment #5: Type: text/plain, Size: 202 bytes --]


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.

-- 
Philipp Haselwarter

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: smtp credential, multiple smtp, posting styles and smtpmail
  2011-02-10 11:33     ` Philipp Haselwarter
@ 2011-02-10 11:58       ` Richard Riley
  2011-02-10 23:19         ` Philipp Haselwarter
  2011-02-10 23:15       ` Richard Riley
  1 sibling, 1 reply; 11+ messages in thread
From: Richard Riley @ 2011-02-10 11:58 UTC (permalink / raw)
  To: Philipp Haselwarter; +Cc: ding

Philipp Haselwarter <philipp.haselwarter@gmx.de> 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.)




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: smtp credential, multiple smtp, posting styles and smtpmail
  2011-02-10 11:33     ` Philipp Haselwarter
  2011-02-10 11:58       ` Richard Riley
@ 2011-02-10 23:15       ` Richard Riley
  1 sibling, 0 replies; 11+ messages in thread
From: Richard Riley @ 2011-02-10 23:15 UTC (permalink / raw)
  To: Philipp Haselwarter; +Cc: ding



Success! With a slight variation. I used a "from" in my
gnus-posting-styles rather than an "address".

,----
| (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."))))
| 
| (setq message-sendmail-envelope-from 'header)
| (add-hook 'message-send-hook 'change-smtp)
| 
| (setq smtp-accounts '(
|                       (ssl "riley" "smtp.gmail.com" "587"
|                            "rileyrg@gmail.com" nil)
|                       (ssl "shamrock" "smtp.gmail.com" "587"
|                            "shamrockirishbar@gmail.com" nil)
| ))
| 
| (setq gnus-posting-styles `((".*"
| 			     (from "Richard Riley <rileyrg@googlemail.com>")
| 			     (eval(setq gnushush-user-agent-header (quote real)))
| 			     (signature-file "~/.emacs.d/.sigs/rgr.sig")
| 			     (eval (setq mml2015-signers '("AB23BE58")))
| 			     (organization "aich tea tea pea dicky riley dot net"))))
|      
| (add-to-list `gnus-posting-styles `(,(rx(or "shamrock"))
| 				    (from  "The Shamrock Irish Bar<shamrock@shamrockirishbar.com>")
| 				    (eval (setq mml2015-signers '("945a4967")))
| 				    (organization "http://www.shamrockirishbar.com")
| 				    (signature-file "~/.emacs.d/.sigs/s.sig")) t)
`----


And the corresponding entry in my authinfo.gpg


,----
| machine riley login rileyrg password *********
| machine shamrockpub login shamrockirishbar password ********
`----

great. I'm not sure, because of my hazy elisp, how its matching against
the authinfo but it does. And the smtp-accounts allow same smtp server
with different authentication credentials.

thanks

r.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: smtp credential, multiple smtp, posting styles and smtpmail
  2011-02-10 11:58       ` Richard Riley
@ 2011-02-10 23:19         ` Philipp Haselwarter
  2011-02-10 23:45           ` Richard Riley
  0 siblings, 1 reply; 11+ messages in thread
From: Philipp Haselwarter @ 2011-02-10 23:19 UTC (permalink / raw)
  To: ding

"RR" == Richard Riley <rileyrg@googlemail.com> writes:

RR> Philipp Haselwarter <philipp.haselwarter@gmx.de> writes:

---8<---[snipped 51 lines: my config]---8<---

RR> Yes, this is similar but superior to what I posted yesterday and
RR> uses a switch to change the smtp server at message send time based
RR> on the address which in turn is set in the gnus posting style. It
RR> was this posting that got me thinking that I ought to be able to set
RR> all I need in the posting style and not need to call the change smtp
RR> function or equivalent.

RR> Since I cant see your .authinfo.gpg, I am assuming it contains names
RR> where the machine names match the second element in the smtp list
RR> elements? This is certainly cleaner than using msmtp and so I'll
RR> give it a go - thanks! Its certainly more comprehensive with the
RR> auth mechs being checked,

err.. the inline authinfo.gpg is a cleartext ascii example corresponding
to the smtp portion in my .authinfo.gpg, K i should show it :)

RR> side note :

RR> (I'm still wonder if I ought to be just be able to set
RR> smtpmail-auth-credentials in the gnus-posting-style and leave the
RR> sendmail program as smtp and it "just work" - or rather I cant see
RR> why it doesnt just work.

RR> e.g '(("smtp.gmail.com" 25 "rileyrg@googlemail.com" "*******"))

RR> in the posting style : then no change-smtp at send stuff is required
RR> and life is even simpler.)

The approach I'm using has the advantage, that you never have to worry
if all the parameters are set correctly, as it just auto-adjusts.
If you choose a semi-static setup with posting styles (supposing that
would work), you'd sort of have to stick with that account for the
group. I can simply add the From: and get everything taken care of.

-- 
Philipp Haselwarter




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: smtp credential, multiple smtp, posting styles and smtpmail
  2011-02-10 23:19         ` Philipp Haselwarter
@ 2011-02-10 23:45           ` Richard Riley
  2011-02-11 14:06             ` Ted Zlatanov
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Riley @ 2011-02-10 23:45 UTC (permalink / raw)
  To: Philipp Haselwarter; +Cc: ding

Philipp Haselwarter <philipp.haselwarter@gmx.de> writes:

> "RR" == Richard Riley <rileyrg@googlemail.com> writes:
>
> RR> Philipp Haselwarter <philipp.haselwarter@gmx.de> writes:
>
> ---8<---[snipped 51 lines: my config]---8<---
>
> RR> Yes, this is similar but superior to what I posted yesterday and
> RR> uses a switch to change the smtp server at message send time based
> RR> on the address which in turn is set in the gnus posting style. It
> RR> was this posting that got me thinking that I ought to be able to set
> RR> all I need in the posting style and not need to call the change smtp
> RR> function or equivalent.
>
> RR> Since I cant see your .authinfo.gpg, I am assuming it contains names
> RR> where the machine names match the second element in the smtp list
> RR> elements? This is certainly cleaner than using msmtp and so I'll
> RR> give it a go - thanks! Its certainly more comprehensive with the
> RR> auth mechs being checked,
>
> err.. the inline authinfo.gpg is a cleartext ascii example corresponding
> to the smtp portion in my .authinfo.gpg, K i should show it :)

Yes, I understand what it is - we discussed it before - but something
was attached to the original post which wouldnt open here (authinfo.gpg)
in my gnus ... dont know why. The ways of mime attachments are many
... . The reason I asked was that it wasnt clear to me what was being
matched : to be honest I still am not sure how authinfo works - its
pretty convoluted - but I do have it working now with the smtp-account
matching - thanks for that - but only after I used "from" in my posting
style and not "address". "works for me" ;)

It now means I dont need to use msmtp so this is great!


> The approach I'm using has the advantage, that you never have to worry
> if all the parameters are set correctly, as it just auto-adjusts.
> If you choose a semi-static setup with posting styles (supposing that
> would work), you'd sort of have to stick with that account for the
> group. I can simply add the From: and get everything taken care of.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: smtp credential, multiple smtp, posting styles and smtpmail
  2011-02-10 23:45           ` Richard Riley
@ 2011-02-11 14:06             ` Ted Zlatanov
  0 siblings, 0 replies; 11+ messages in thread
From: Ted Zlatanov @ 2011-02-11 14:06 UTC (permalink / raw)
  To: ding

On Fri, 11 Feb 2011 00:45:53 +0100 Richard Riley <rileyrg@googlemail.com> wrote: 

RR> to be honest I still am not sure how authinfo works - its pretty
RR> convoluted

The *current* version of auth-source.el is documented in auth.texi.  I
think the examples are pretty clear.

The *new* version of auth-source.el in the tzz-auth-source-rewrite
branch has documentation in the docstring of `auth-source-search' and I
will update the manual in that branch as well.  It works very similarly
to the current version as far as the contents of the authinfo/netrc
file.  It can adapt to handle more backends, though.  So you could write
your own backend that took a search (e.g. :host x :user y :port z) and
returned whatever data you want statically, based on the search, or
based on other factors.

Ted




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: smtp credential, multiple smtp, posting styles and smtpmail
  2011-02-10  9:03 smtp credential, multiple smtp, posting styles and smtpmail Richard Riley
  2011-02-10  9:20 ` Julien Danjou
@ 2011-02-14  2:20 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 11+ messages in thread
From: Lars Ingebrigtsen @ 2011-02-14  2:20 UTC (permalink / raw)
  To: ding

Richard Riley <rileyrg@googlemail.com> writes:

> Does someone have a way of extracting/setting the correct credentials
> for smtp posting based on the contents of .authinfo.gpg when using
> gnus-posting-styles?
>
> The problem with msmtp is that the data is in cleartext.

This seems to have been resolved, but it reminds me of two things:

1) I guess smtpmail.el should use open-protocol-stream to get STARTTLS
support for all SMTP server that support it.  (SMTP servers do support
STARTTLS these days, don't they?)

2) When I installed Ubuntu on this laptop, it had a totally non-working
mail setup by default.  It wouldn't send out any mail.  It would only do
local delivery.  That's kinda weird.  But Message should probably
discover this sorry state of affairs and default to using smtpmail.el
and prompt for the SMTP address to use, perhaps?  Opinions and thoughts?

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-02-14  2:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-10  9:03 smtp credential, multiple smtp, posting styles and smtpmail Richard Riley
2011-02-10  9:20 ` Julien Danjou
2011-02-10  9:36   ` Richard Riley
2011-02-10 11:33     ` Philipp Haselwarter
2011-02-10 11:58       ` Richard Riley
2011-02-10 23:19         ` Philipp Haselwarter
2011-02-10 23:45           ` Richard Riley
2011-02-11 14:06             ` Ted Zlatanov
2011-02-10 23:15       ` Richard Riley
     [not found]   ` <ygfd3n0nrpj.fsf_-_@vserv.viteno.net>
     [not found]     ` <87y65ouqa5.fsf@keller.adm.naquadah.org>
2011-02-10 11:21       ` Your public key Norbert Koch
2011-02-14  2:20 ` smtp credential, multiple smtp, posting styles and smtpmail Lars Ingebrigtsen

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).