diff options
-rw-r--r-- | gnus-conf.el | 78 | ||||
-rw-r--r-- | mail.el | 7 |
2 files changed, 82 insertions, 3 deletions
diff --git a/gnus-conf.el b/gnus-conf.el index 9546063..7d0fa23 100644 --- a/gnus-conf.el +++ b/gnus-conf.el @@ -7,7 +7,8 @@ (setq gnus-select-method '(nnnil "")) (setq gnus-secondary-select-methods '(;; (nntp "news.gmane.io") - (nnmaildir "private" (directory "~/.nnmaildir")) + (nnmaildir "gmail" (directory "~/.nnmaildir/gmail")) + (nnmaildir "durand" (directory "~/.nnmaildir/mymail")) ;; (nnmaildir "sent" (directory "~/.nnmaildir")) ;; (nnimap "LocalMail" ;; (nnimap-address "localhost") @@ -91,7 +92,7 @@ (setq gnus-ignored-from-addresses "mmemmew@gmail.com") (setq send-mail-function #'smtpmail-send-it) -(setq smtpmail-smtp-user "mmemmew@gmail.com") +(setq smtpmail-smtp-user "durand@jsdurand.xyz") (setq gnus-user-agent '(emacs gnus config)) @@ -129,6 +130,76 @@ (setq gnus-gcc-mark-as-read t) +;;; Multiple SMTP servers + +(defvar durand-smtp-servers nil + "The list of SMTP servers that I use. +Each server is a list of the form: + +(SENDER SERVER PORT USERNAME) + +SENDER is a string to match the \"FROM\" field of EMails. + +SERVER is the server to use. + +PORT is the port to use. + +USERNAME is used to look up passwords in ~/.authinfo.gpg.") + +(setq durand-smtp-servers + (list + (list "durand@jsdurand.xyz" + "mail.jsdurand.xyz" + 587 + "durand@jsdurand.xyz") + (list "mmemmew@gmail.com" + "smtp.gmail.com" + 587 + "mmemmew@gmail.com"))) + +(defun durand-set-smtp-server-message-send-and-exit () + "Set SMTP server according to `durand-smtp-servers' and send mail." + (interactive) + ;; We always determine this automatically. + (message-remove-header "X-Message-SMTP-Method") + (let* ((sender (message-fetch-field "From")) + (server-form (alist-get sender durand-smtp-servers + nil nil #'string-match-p))) + (cond + ((and (null server-form) + (y-or-n-p + "Do you want to change the default SMTP server?")) + (setq server-form + (alist-get (completing-read "Choose a server: " + durand-smtp-servers + nil t) + durand-smtp-servers + nil nil #'string=)))) + ;; if there is a server to use, we change to it + (cond + (server-form + (message-add-header + (format + "X-Message-SMTP-Method: smtp %s %d %s" + (car server-form) (cadr server-form) (caddr server-form))))) + ;; send the message if possible + (let ((xmess (message-fetch-field "X-Message-SMTP-Method"))) + (cond + (xmess + (message + (format "Sending message using '%s' with config '%s'" + sender xmess)) + (message-send-and-exit)) + (user-error + (concat + "Could not find SMTP Server for this Sender address: %s." + "You might want to correct it or add it to " + "the list 'durand-smtp-servers'.") + sender))))) + +(define-key message-mode-map (vector 3 3) + #'durand-set-smtp-server-message-send-and-exit) + ;;; Call me an expert. (setq gnus-expert-user t) @@ -281,3 +352,6 @@ ;; Don't query me each time (setq sc-confirm-always-p nil) + +(provide 'gnus-conf) +;;; gnus-conf.el ends here @@ -12,7 +12,9 @@ (setq mu4e-view-use-gnus t) (setq mu4e-confirm-quit nil) - (setq mu4e-get-mail-command "mbsync -a") ; mbsync works a lot better! + ;; mbsync works a lot better! + (setq mu4e-get-mail-command + "mbsync mymail-inbox mymail-sent gmail-inbox gmail-sent") (setq mu4e-change-filenames-when-moving t) (setq mu4e-view-show-addresses t) ; show full addresses! (setq mu4e-view-show-images t) @@ -107,6 +109,9 @@ (smtpmail-smtp-server . "smtp.gmail.com") (smtpmail-smtp-service . 587)))))) +;; (setq smtpmail-debug-info t) +;; (setq smtpmail-debug-verb t) + ;;; message mode (require 'message) |