diff options
| author | Michael Albinus | 2021-07-23 20:30:46 +0200 |
|---|---|---|
| committer | Michael Albinus | 2021-07-23 20:30:46 +0200 |
| commit | 8ec35857cf0ae3a18e2267cd8460cf898bcb338f (patch) | |
| tree | 804fd4726badcfbe70ea8031803962d81bbc382a | |
| parent | eb20d013a1717a0ecc6ee3563e69261aaf7c98eb (diff) | |
| parent | 2a231378fa5b10049b52c9197f037b522e0d22a1 (diff) | |
| download | emacs-8ec35857cf0ae3a18e2267cd8460cf898bcb338f.tar.gz emacs-8ec35857cf0ae3a18e2267cd8460cf898bcb338f.zip | |
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
| -rw-r--r-- | doc/misc/smtpmail.texi | 10 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/files.el | 2 | ||||
| -rw-r--r-- | lisp/gnus/message.el | 4 | ||||
| -rw-r--r-- | lisp/mail/smtpmail.el | 80 |
5 files changed, 70 insertions, 31 deletions
diff --git a/doc/misc/smtpmail.texi b/doc/misc/smtpmail.texi index dd481d2101e..8a19744f91b 100644 --- a/doc/misc/smtpmail.texi +++ b/doc/misc/smtpmail.texi | |||
| @@ -338,6 +338,16 @@ not sent immediately but rather queued in the directory | |||
| 338 | @code{smtpmail-send-queued-mail} (typically when you connect to the | 338 | @code{smtpmail-send-queued-mail} (typically when you connect to the |
| 339 | internet). | 339 | internet). |
| 340 | 340 | ||
| 341 | @item smtpmail-store-queue-variables | ||
| 342 | @vindex smtpmail-store-queue-variables | ||
| 343 | Normally the queue will be dispatched with the values of the | ||
| 344 | @acronym{SMTP} variables that are in effect when @kbd{M-x | ||
| 345 | smtpmail-send-queued-mail} is executed, but if this | ||
| 346 | @code{smtpmail-store-queue-variables} is non-@code{nil}, the values | ||
| 347 | for @code{smtpmail-smtp-server} (etc.) will be stored when the mail is | ||
| 348 | queued, and then used when actually sending the mail. This can be | ||
| 349 | useful if you have a complex outgoing mail setup. | ||
| 350 | |||
| 341 | @item smtpmail-queue-dir | 351 | @item smtpmail-queue-dir |
| 342 | @vindex smtpmail-queue-dir | 352 | @vindex smtpmail-queue-dir |
| 343 | The variable @code{smtpmail-queue-dir} specifies the name of the | 353 | The variable @code{smtpmail-queue-dir} specifies the name of the |
| @@ -1144,6 +1144,11 @@ take the actual screenshot, and defaults to "ImageMagick import". | |||
| 1144 | ** Smtpmail | 1144 | ** Smtpmail |
| 1145 | 1145 | ||
| 1146 | +++ | 1146 | +++ |
| 1147 | *** New user option 'smtpmail-store-queue-variables'. | ||
| 1148 | If non-nil, SMTP variables will be stored in the queue and then used | ||
| 1149 | when sending with 'M-x smtpmail-send-queued-mail'. | ||
| 1150 | |||
| 1151 | +++ | ||
| 1147 | *** Allow direct selection of smtp authentication mechanism. | 1152 | *** Allow direct selection of smtp authentication mechanism. |
| 1148 | A server entry retrieved by auth-source can request a desired smtp | 1153 | A server entry retrieved by auth-source can request a desired smtp |
| 1149 | authentication mechanism by setting a value for the key 'smtp-auth'. | 1154 | authentication mechanism by setting a value for the key 'smtp-auth'. |
diff --git a/lisp/files.el b/lisp/files.el index dc803d3a4cf..c0effd1ad6b 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -3221,7 +3221,7 @@ call is via directory-locals and extra checks should be done." | |||
| 3221 | (if case-insensitive-p | 3221 | (if case-insensitive-p |
| 3222 | ;; Filesystem is case-insensitive. | 3222 | ;; Filesystem is case-insensitive. |
| 3223 | (let ((case-fold-search t)) | 3223 | (let ((case-fold-search t)) |
| 3224 | (assoc-default alist 'string-match)) | 3224 | (assoc-default name alist 'string-match)) |
| 3225 | ;; Filesystem is case-sensitive. | 3225 | ;; Filesystem is case-sensitive. |
| 3226 | (or | 3226 | (or |
| 3227 | ;; First match case-sensitively. | 3227 | ;; First match case-sensitively. |
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index cdabdef2ec8..9baf09b0268 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el | |||
| @@ -4922,6 +4922,7 @@ Each line should be no more than 79 characters long." | |||
| 4922 | (defvar smtpmail-smtp-service) | 4922 | (defvar smtpmail-smtp-service) |
| 4923 | (defvar smtpmail-smtp-user) | 4923 | (defvar smtpmail-smtp-user) |
| 4924 | (defvar smtpmail-stream-type) | 4924 | (defvar smtpmail-stream-type) |
| 4925 | (defvar smtpmail-store-queue-variables) | ||
| 4925 | 4926 | ||
| 4926 | (defun message-multi-smtp-send-mail () | 4927 | (defun message-multi-smtp-send-mail () |
| 4927 | "Send the current buffer to `message-send-mail-function'. | 4928 | "Send the current buffer to `message-send-mail-function'. |
| @@ -4937,7 +4938,8 @@ that instead." | |||
| 4937 | (message-send-mail-with-sendmail)) | 4938 | (message-send-mail-with-sendmail)) |
| 4938 | ((equal (car method) "smtp") | 4939 | ((equal (car method) "smtp") |
| 4939 | (require 'smtpmail) | 4940 | (require 'smtpmail) |
| 4940 | (let* ((smtpmail-smtp-server (nth 1 method)) | 4941 | (let* ((smtpmail-store-queue-variables t) |
| 4942 | (smtpmail-smtp-server (nth 1 method)) | ||
| 4941 | (service (nth 2 method)) | 4943 | (service (nth 2 method)) |
| 4942 | (port (string-to-number service)) | 4944 | (port (string-to-number service)) |
| 4943 | ;; If we're talking to the TLS SMTP port, then force a | 4945 | ;; If we're talking to the TLS SMTP port, then force a |
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index c1e22800331..133a2e1828e 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el | |||
| @@ -135,8 +135,9 @@ Used for the value of `sendmail-coding-system' when | |||
| 135 | 135 | ||
| 136 | (defcustom smtpmail-queue-mail nil | 136 | (defcustom smtpmail-queue-mail nil |
| 137 | "Non-nil means mail is queued; otherwise it is sent immediately. | 137 | "Non-nil means mail is queued; otherwise it is sent immediately. |
| 138 | If queued, it is stored in the directory `smtpmail-queue-dir' | 138 | If queued, it is stored in the directory `smtpmail-queue-dir' and |
| 139 | and sent with `smtpmail-send-queued-mail'." | 139 | sent with `smtpmail-send-queued-mail'. Also see |
| 140 | `smtpmail-store-queue-variables'." | ||
| 140 | :type 'boolean) | 141 | :type 'boolean) |
| 141 | 142 | ||
| 142 | (defcustom smtpmail-queue-dir "~/Mail/queued-mail/" | 143 | (defcustom smtpmail-queue-dir "~/Mail/queued-mail/" |
| @@ -173,10 +174,21 @@ mean \"try again\"." | |||
| 173 | :type 'integer | 174 | :type 'integer |
| 174 | :version "27.1") | 175 | :version "27.1") |
| 175 | 176 | ||
| 177 | (defcustom smtpmail-store-queue-variables nil | ||
| 178 | "If non-nil, store SMTP variables when queueing mail. | ||
| 179 | These will then be used when sending the queue." | ||
| 180 | :type 'boolean | ||
| 181 | :version "28.1") | ||
| 182 | |||
| 176 | ;;; Variables | 183 | ;;; Variables |
| 177 | 184 | ||
| 178 | (defvar smtpmail-address-buffer) | 185 | (defvar smtpmail-address-buffer) |
| 179 | (defvar smtpmail-recipient-address-list) | 186 | (defvar smtpmail-recipient-address-list nil) |
| 187 | (defvar smtpmail--stored-queue-variables | ||
| 188 | '(smtpmail-smtp-server | ||
| 189 | smtpmail-stream-type | ||
| 190 | smtpmail-smtp-service | ||
| 191 | smtpmail-smtp-user)) | ||
| 180 | 192 | ||
| 181 | (defvar smtpmail-queue-counter 0) | 193 | (defvar smtpmail-queue-counter 0) |
| 182 | 194 | ||
| @@ -387,11 +399,17 @@ for `smtpmail-try-auth-method'.") | |||
| 387 | nil t) | 399 | nil t) |
| 388 | (insert-buffer-substring tembuf) | 400 | (insert-buffer-substring tembuf) |
| 389 | (write-file file-data) | 401 | (write-file file-data) |
| 390 | (write-region | 402 | (let ((coding-system-for-write 'utf-8)) |
| 391 | (concat "(setq smtpmail-recipient-address-list '" | 403 | (with-temp-buffer |
| 392 | (prin1-to-string smtpmail-recipient-address-list) | 404 | (insert "(setq ") |
| 393 | ")\n") | 405 | (dolist (var (cons 'smtpmail-recipient-address-list |
| 394 | nil file-elisp nil 'silent) | 406 | ;; Perhaps store the server etc. |
| 407 | (and smtpmail-store-queue-variables | ||
| 408 | smtpmail--stored-queue-variables))) | ||
| 409 | (insert (format " %s %S\n" var (symbol-value var)))) | ||
| 410 | (insert ")\n") | ||
| 411 | (write-region (point-min) (point-max) file-elisp | ||
| 412 | nil 'silent))) | ||
| 395 | (write-region (concat file-data "\n") nil | 413 | (write-region (concat file-data "\n") nil |
| 396 | (expand-file-name smtpmail-queue-index-file | 414 | (expand-file-name smtpmail-queue-index-file |
| 397 | smtpmail-queue-dir) | 415 | smtpmail-queue-dir) |
| @@ -411,26 +429,30 @@ for `smtpmail-try-auth-method'.") | |||
| 411 | (let (file-data file-elisp | 429 | (let (file-data file-elisp |
| 412 | (qfile (expand-file-name smtpmail-queue-index-file | 430 | (qfile (expand-file-name smtpmail-queue-index-file |
| 413 | smtpmail-queue-dir)) | 431 | smtpmail-queue-dir)) |
| 432 | (stored (cons 'smtpmail-recipient-address-list | ||
| 433 | smtpmail--stored-queue-variables)) | ||
| 434 | smtpmail-recipient-address-list | ||
| 435 | (smtpmail-smtp-server smtpmail-smtp-server) | ||
| 436 | (smtpmail-stream-type smtpmail-stream-type) | ||
| 437 | (smtpmail-smtp-service smtpmail-smtp-service) | ||
| 438 | (smtpmail-smtp-user smtpmail-smtp-user) | ||
| 414 | result) | 439 | result) |
| 415 | (insert-file-contents qfile) | 440 | (insert-file-contents qfile) |
| 416 | (goto-char (point-min)) | 441 | (goto-char (point-min)) |
| 417 | (while (not (eobp)) | 442 | (while (not (eobp)) |
| 418 | (setq file-data (buffer-substring (point) (line-end-position))) | 443 | (setq file-data (buffer-substring (point) (line-end-position))) |
| 419 | (setq file-elisp (concat file-data ".el")) | 444 | (setq file-elisp (concat file-data ".el")) |
| 420 | ;; FIXME: Avoid `load' which can execute arbitrary code and is hence | 445 | (let ((coding-system-for-read 'utf-8)) |
| 421 | ;; a source of security holes. Better read the file and extract the | 446 | (with-temp-buffer |
| 422 | ;; data "by hand". | 447 | (insert-file-contents file-elisp) |
| 423 | ;;(load file-elisp) | 448 | (let ((form (read (current-buffer)))) |
| 424 | (with-temp-buffer | 449 | (when (or (not (consp form)) |
| 425 | (insert-file-contents file-elisp) | 450 | (not (eq (car form) 'setq)) |
| 426 | (goto-char (point-min)) | 451 | (not (consp (cdr form)))) |
| 427 | (pcase (read (current-buffer)) | 452 | (error "Unexpected code in %S: %S" file-elisp form)) |
| 428 | (`(setq smtpmail-recipient-address-list ',v) | 453 | (cl-loop for (var val) on (cdr form) by #'cddr |
| 429 | (skip-chars-forward " \n\t") | 454 | when (memq var stored) |
| 430 | (unless (eobp) (message "Ignoring trailing text in %S" | 455 | do (set var val))))) |
| 431 | file-elisp)) | ||
| 432 | (setq smtpmail-recipient-address-list v)) | ||
| 433 | (sexp (error "Unexpected code in %S: %S" file-elisp sexp)))) | ||
| 434 | ;; Insert the message literally: it is already encoded as per | 456 | ;; Insert the message literally: it is already encoded as per |
| 435 | ;; the MIME headers, and code conversions might guess the | 457 | ;; the MIME headers, and code conversions might guess the |
| 436 | ;; encoding wrongly. | 458 | ;; encoding wrongly. |
| @@ -445,13 +467,13 @@ for `smtpmail-try-auth-method'.") | |||
| 445 | (message-narrow-to-headers) | 467 | (message-narrow-to-headers) |
| 446 | (mail-envelope-from))) | 468 | (mail-envelope-from))) |
| 447 | user-mail-address))) | 469 | user-mail-address))) |
| 448 | (if (not (null smtpmail-recipient-address-list)) | 470 | (if (not smtpmail-recipient-address-list) |
| 449 | (when (setq result (smtpmail-via-smtp | 471 | (error "Sending failed; no recipients") |
| 450 | smtpmail-recipient-address-list | 472 | (when (setq result (smtpmail-via-smtp |
| 451 | (current-buffer))) | 473 | smtpmail-recipient-address-list |
| 452 | (error "Sending failed: %s" | 474 | (current-buffer))) |
| 453 | (smtpmail--sanitize-error-message result))) | 475 | (error "Sending failed: %s" |
| 454 | (error "Sending failed; no recipients")))) | 476 | (smtpmail--sanitize-error-message result)))))) |
| 455 | (delete-file file-data) | 477 | (delete-file file-data) |
| 456 | (delete-file file-elisp) | 478 | (delete-file file-elisp) |
| 457 | (delete-region (point-at-bol) (point-at-bol 2))) | 479 | (delete-region (point-at-bol) (point-at-bol 2))) |