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: Thu, 10 Feb 2011 12:58:56 +0100	[thread overview]
Message-ID: <2pmxm4drz6.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")

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




  reply	other threads:[~2011-02-10 11:58 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 [this message]
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

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=2pmxm4drz6.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).