emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Make `smtpmail-try-auth-method' a generic function.


From: Robert Pluim
Subject: Re: [PATCH] Make `smtpmail-try-auth-method' a generic function.
Date: Thu, 11 Jan 2018 15:42:23 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)

Cesar Crusius <address@hidden> writes:

> This allows for extra authentication mechanisms (such as XOAuth2) to
> be added without having to advise any functions.
>
> * lisp/mail/smtpmail.el: Turn `smtpmail-try-auth-method' into a
> generic function.
> ---
>  lisp/mail/smtpmail.el | 33 +++++++++++++++++++++++++++++++--
>  1 file changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
> index 20cbeb5f4e..46c1639832 100644
> --- a/lisp/mail/smtpmail.el
> +++ b/lisp/mail/smtpmail.el
> @@ -181,7 +181,25 @@ This is relative to `smtpmail-queue-dir'."
>  
>  (defconst smtpmail-auth-supported '(cram-md5 plain login)
>    "List of supported SMTP AUTH mechanisms.
> -The list is in preference order.")
> +The list is in preference order.
> +
> +New mechanisms can be added by defining a method implementing the
> +`smtpmail-try-auth-method' generic function for that mechanism, and
> +then adding the mechanism to this list.  As an example, the code below
> +adds support for XOAuth2 authentication (assuming that there is an
> +appropriate auth source extension that can provide the correct user
> +and password):
> +
> +\(cl-defmethod smtpmail-try-auth-method
> +    (process (mech (eql xoauth2)) user password)
> +  (smtpmail-command-or-throw
> +   process
> +   (concat \"AUTH XOAUTH2 \"
> +           (base64-encode-string
> +            (concat \"user=\" user \"\\1auth=Bearer \" password \"\\1\\1\") 
> t))
> +   235))
> +
> +\(add-to-list 'smtpmail-try-auth-method 'xoauth2)")
                  ^^^^^^^^^^^^^^^^^^^^^^^^
This should say smtpmail-auth-supported, no?

FWIW, I've tried your patch, and it doesn't break anything for me with
gmail, although I haven't tried enabling XOAuth2 yet.

Robert

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]