Gnus development mailing list
 help / color / mirror / Atom feed
From: Richard Riley <rileyrg@googlemail.com>
To: Philipp Haselwarter <philipp.haselwarter@gmx.de>
Cc: ding@gnus.org
Subject: Re: smtp credential, multiple smtp, posting styles and smtpmail
Date: Fri, 11 Feb 2011 00:15:30 +0100	[thread overview]
Message-ID: <ws62sr8orx.fsf@news.eternal-september.org> (raw)
In-Reply-To: <87ipws86pn.fsf@netarch.haselwarter.org> (Philipp Haselwarter's message of "Thu, 10 Feb 2011 12:33:24 +0100")



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.



  parent reply	other threads:[~2011-02-10 23:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-10  9:03 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 [this message]
     [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

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=ws62sr8orx.fsf@news.eternal-september.org \
    --to=rileyrg@googlemail.com \
    --cc=ding@gnus.org \
    --cc=philipp.haselwarter@gmx.de \
    /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).