dot.gnus.el 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ;; ---------- ---------- ---------- ---------- ---------- ---------- ----------
  2. ;;
  3. ;; NOTE: This will contain examples for:
  4. ;; ~/.gnus
  5. ;;
  6. ;; ALSO: https://www.emacswiki.org/emacs/MultipleSMTPAccounts
  7. ;; https://github.com/redguardtoo/mastering-emacs-in-one-year-guide/blob/master/gnus-guide-en.org
  8. ;;
  9. ;; ---------- ---------- ---------- ---------- ---------- ---------- ----------
  10. ;; List of email addresses and respective smtp:
  11. ;; (user-mail-address
  12. ;; user-full-name
  13. ;; message-send-mail-function/send-mail-function
  14. ;; smtpmail-default-smtp-server/smtpmail-smtp-server
  15. ;; smtpmail-smtp-service
  16. ;; smtpmail-stream-type)
  17. (setq my-email-addresses
  18. '(("foo@bar.glux" "foo" smtpmail-send-it "smtp.bar.glux" 465 ssl))
  19. ;; News servers
  20. (setq gnus-select-method
  21. '(nntp "news.gnus.org"))
  22. (setq gnus-secondary-select-methods
  23. '((nntp "news.gmane.org")
  24. (nntp "news.mozilla.org")))
  25. ;; General identity
  26. (setq user-mail-address
  27. (nth 0 (nth 0 my-email-addresses))
  28. user-full-name
  29. (nth 1 (nth 0 my-email-addresses)))
  30. ;; Mail servers; just using gnus-secondary-select-methods.
  31. ;; (setq gnus-select-method
  32. ;; '(nnimap "foo@bar.glux"))
  33. (setq gnus-secondary-select-methods
  34. '((nnimap "foo.at.bar.glux"
  35. (nnimap-address "mail.bar.glux")
  36. (nnimap-server-port "imaps")
  37. (nnimap-stream ssl))
  38. (nnimap "foo.at.tanj.glux"
  39. (nnimap-address "imap.tanj.glux")
  40. (nnimap-server-port "imaps")
  41. (nnimap-stream ssl))
  42. (nnimap "foo.at.norf.glux"
  43. (nnimap-address "mailmail.norf.glux")
  44. (nnimap-server-port "imaps")
  45. (nnimap-stream ssl))))
  46. ;;NOTE: Update the message-mode settings to send with the correct account.
  47. (setq my-email-addresses-index 0)
  48. (defun smtpmail-loop-smtp-server ()
  49. (interactive)
  50. ;;restart index position
  51. (if (eq my-email-addresses-index (length my-email-addresses))
  52. (setq my-email-addresses-index 0) nil)
  53. ;;update email, name, and smtp infos
  54. (setq user-mail-address
  55. (nth 0 (nth my-email-addresses-index my-email-addresses))
  56. user-full-name
  57. (nth 1 (nth my-email-addresses-index my-email-addresses))
  58. message-send-mail-function
  59. (nth 2 (nth my-email-addresses-index my-email-addresses))
  60. send-mail-function
  61. (nth 2 (nth my-email-addresses-index my-email-addresses))
  62. smtpmail-default-smtp-server
  63. (nth 3 (nth my-email-addresses-index my-email-addresses))
  64. smtpmail-smtp-server
  65. (nth 3 (nth my-email-addresses-index my-email-addresses))
  66. smtpmail-smtp-service
  67. (nth 4 (nth my-email-addresses-index my-email-addresses))
  68. smtpmail-stream-type
  69. (nth 5 (nth my-email-addresses-index my-email-addresses)))
  70. (setq smtpmail-auth-credentials
  71. '((smtpmail-smtp-server smtpmail-smtp-service user-mail-address nil)))
  72. (setq current-from (concat "From: " user-full-name " <" user-mail-address ">"))
  73. ;;save position, replace the from field
  74. (setq message-article-current-point (point))
  75. (goto-char (point-min))
  76. (while (re-search-forward "^From:.*$" nil t)
  77. (replace-match current-from))
  78. (goto-char message-article-current-point)
  79. ;;advance index position, prompt
  80. (setq my-email-addresses-index (+ my-email-addresses-index 1))
  81. (message current-from))
  82. (global-set-key (kbd "C-s-g") 'smtpmail-loop-smtp-server)