 
 ;;; Mail Formatting
 
+;; XXX: This should actually be set by the customize setter of
+;; `db/mail-accounts’
 (setq gnus-posting-styles
-      `((".*"
-         (name ,user-full-name)
-         (address ,user-mail-address)
-         (signature-file "~/.signature")
-         ("X-Jabber-ID" ,db/jabber-id))))
+      (append
+       `((".*"
+          (name ,user-full-name)
+          (address ,user-mail-address)
+          (signature-file "~/.signature")
+          ("X-Jabber-ID" ,db/jabber-id)))
+       (mapcar (lambda (account)
+                 (let ((account-name (nth 1 account))
+                       (account-address (nth 0 account)))
+                   `(,(concat account-name ":")
+                     (name ,user-full-name)
+                     (address ,account-address)
+                     (signature-file "~/.signature")
+                     ("X-Jabber-ID" ,db/jabber-id))))
+               db/mail-accounts)))
 
 ;; http://mbork.pl/2015-11-28_Fixing_mml-attach-file_using_advice
 (defun db/mml-attach-file--go-to-eob (orig-fun &rest args)


;; Customization

(defcustom db/smtp-accounts nil
  "Configuration for sending mail as used by `db/set-smtp-server-from-header’, which see.
This is a list of lists, where each such list specifies the SMTP
parameters for one particular email address.  This specification
consists of the mail address, the address of the mail server, the
stream type (e.g. `starttls’), the SMTP service port, and the
SMTP user."
  :group 'personal-settings
  :type '(repeat
          (list
           (string :tag "EMail Address")
           (string :tag "SMTP Server Address")
           (choice :tag "SMTP Stream Type"
            (const nil) (const starttls) (const plain) (const ssl))
           (integer :tag "SMTP Service Port")
           (string :tag "SMTP Login Name"))))


      smtpmail-smtp-service 587
      starttls-use-gnutls t
      starttls-extra-arguments '("--strict-tofu")
      smtpmail-smtp-server (nth 3 (car db/mail-accounts))
      smtpmail-smtp-user (nth 6 (car db/mail-accounts)))

(defun db/set-smtp-server-from-header (orig-fun &rest args)
  "Choose smtp-settings dynamically, based on the From: header
