;;; Code:
(require 'esy-o365)
-(require 'savehist)
(defvar esy-comm-accounts
'(("me"
"%2{%~(form (replace-regexp-in-string \" via .*\" \"\" (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)))@%} "
"%3{(%&user-date;, %k)%}:%* %s\n"))
-(defun esy-comm--mail-from ()
- (without-restriction
- (message-narrow-to-headers)
- (when-let ((from (mail-fetch-field "from")))
- (cadr (mail-extract-address-components from)))))
-
-(defun esy-comm-send-message ()
- (require 'smtpmail)
- (if-let ((from (esy-comm--mail-from))
- (server (alist-get from
- (mapcar (pcase-lambda
- (`(,_ ,car ,_ ,cdr . ,_))
- (cons car cdr))
- esy-comm-accounts)
- nil nil #'string=)))
- (let ((smtpmail-smtp-user from)
- (smtpmail-smtp-server server)
- (smtpmail-smtp-service 587)
- (smtpmail-stream-type 'starttls)
- (smtpmail-servers-requiring-authorization ".*"))
- (smtpmail-send-it))
- (user-error "Unrecognized FROM address, not sending")))
-
(setq
- ;; sendmail.el
- send-mail-function #'esy-comm-send-message
-
;; Message
- message-send-mail-function #'esy-comm-send-message
message-alternative-emails (regexp-opt (mapcar #'cadr esy-comm-accounts))
+ message-dont-reply-to-names message-alternative-emails
+ message-elide-ellipsis "\n[...%l lines elided...]\n"
+ message-server-alist (mapcar (pcase-lambda
+ (`(,_ ,cond ,_ ,server . ,_))
+ (cons cond
+ (format "smtp %s 587" server)))
+ esy-comm-accounts)
;; Gnus
gnus-expert-user t
(with-eval-after-load 'message
(add-hook 'message-send-hook 'ispell-message))
-(with-eval-after-load 'savehist
- (add-to-list 'savehist-additional-variables
- 'esy-o365-token-refresh-last-time))
-
(provide 'esy-comm)
;;; esy-comm.el ends here