Function: sieve-manage-open-server

sieve-manage-open-server is a byte-compiled function defined in sieve-manage.el.gz.

Signature

(sieve-manage-open-server SERVER PORT &optional STREAM BUFFER)

Documentation

Open network connection to SERVER on PORT.

Return the buffer associated with the connection.

Source Code

;; Defined in /usr/src/emacs/lisp/net/sieve-manage.el.gz
(defun sieve-manage-open-server (server port &optional stream buffer)
  "Open network connection to SERVER on PORT.
Return the buffer associated with the connection."
  (with-current-buffer buffer
    (sieve-manage-erase)
    (setq sieve-manage-state 'initial)
    (pcase-let ((`(,proc . ,props)
                 (open-network-stream
                  "SIEVE" buffer server port
                  :type stream
                  ;; eol type unix is required to preserve "\r\n"
                  :coding 'raw-text-unix
                  :capability-command "CAPABILITY\r\n"
                  :end-of-command "^\\(OK\\|NO\\).*\n"
                  :success "^OK.*\n"
                  :return-list t
                  :starttls-function
                  (lambda (capabilities)
                    (when (and (not sieve-manage-ignore-starttls)
                               (string-match "\\bSTARTTLS\\b" capabilities))
                      "STARTTLS\r\n")))))
      (setq sieve-manage-process proc)
      (setq sieve-manage-capability
            (sieve-manage-parse-capability (plist-get props :capabilities)))
      ;; Ignore new capabilities issues after successful STARTTLS
      (when (or sieve-manage-ignore-starttls
		(and (memq stream '(nil network starttls))
		     (eq (plist-get props :type) 'tls)))
        (sieve-manage-drop-next-answer))
      (current-buffer))))