                         (mail-fetch-field "From"))
                       user-mail-address))
          (address (cadr (mail-extract-address-components from)))
-         ;; db/smtp-accounts set in db-private
-         (account (assoc address db/smtp-accounts)))
+         (account (assoc address db/mail-accounts)))
     (message "Using address: %s" address)
     (if account
         (progn
           (message "Sending with account for %s" address)
-          (cl-destructuring-bind (smtpmail-smtp-server
-                                  smtpmail-stream-type
-                                  smtpmail-smtp-service
-                                  smtpmail-smtp-user)
-              (cdr account)
+          (let ((smtpmail-smtp-server (nth 3 account))
+                (smtpmail-stream-type (nth 4 account))
+                (smtpmail-smtp-service (nth 5 account))
+                (smtpmail-smtp-user (nth 6 account)))
             (apply orig-fun args)))
       (progn
         (message "Sending with default account settings")


;; 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"))))



;;; Mail Formatting

;; XXX: This should actually be set by the customize setter of
;; `db/mail-accounts’
(setq gnus-posting-styles
      (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)
