1 ;;; smtp.el --- basic functions to send mail with SMTP server
3 ;; Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001 ,2002, 2004
4 ;; Free Software Foundation, Inc.
6 ;; Author: Tomoji Kagatani <kagatani@rbc.ncl.omron.co.jp>
7 ;; Simon Leinen <simon@switch.ch> (ESMTP support)
8 ;; Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
9 ;; Daiki Ueno <ueno@unixuser.org>
10 ;; Keywords: SMTP, mail
12 ;; This file is part of FLIM (Faithful Library about Internet Message).
14 ;; This program is free software; you can redistribute it and/or
15 ;; modify it under the terms of the GNU General Public License as
16 ;; published by the Free Software Foundation; either version 2, or (at
17 ;; your option) any later version.
19 ;; This program is distributed in the hope that it will be useful, but
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 ;; General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with this program; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 ;; Boston, MA 02110-1301, USA.
36 (require 'mail-utils) ; mail-strip-quoted-names
39 (require 'mel) ; binary-funcall
42 "SMTP protocol for sending mail."
45 (defgroup smtp-extensions nil
46 "SMTP service extensions (RFC1869)."
49 (defcustom smtp-default-server nil
50 "Specify default SMTP server."
51 :type '(choice (const nil) string)
54 (defcustom smtp-server (or (getenv "SMTPSERVER") smtp-default-server)
55 "The name of the host running SMTP server.
56 It can also be a function
57 called from `smtp-via-smtp' with arguments SENDER and RECIPIENTS."
58 :type '(choice (string :tag "Name")
59 (function :tag "Function"))
62 (defcustom smtp-send-by-myself nil
63 "If non-nil, smtp.el send a mail by myself without smtp-server.
64 This option requires \"dig.el\"."
68 (defcustom smtp-service "smtp"
69 "SMTP service port number. \"smtp\" or 25."
70 :type '(choice (integer :tag "25" 25)
71 (string :tag "smtp" "smtp"))
74 (defcustom smtp-local-domain nil
75 "Local domain name without a host name.
76 If the function (system-name) returns the full internet address,
77 don't define this value."
78 :type '(choice (const nil) string)
81 (defcustom smtp-fqdn nil
82 "Fully qualified domain name used for Message-ID."
83 :type '(choice (const nil) string)
86 (defcustom smtp-use-8bitmime t
87 "If non-nil, use ESMTP 8BITMIME (RFC1652) if available."
89 :group 'smtp-extensions)
91 (defcustom smtp-use-size t
92 "If non-nil, use ESMTP SIZE (RFC1870) if available."
94 :group 'smtp-extensions)
96 (defcustom smtp-use-starttls nil
97 "If non-nil, use STARTTLS (RFC2595) if available."
99 :group 'smtp-extensions)
101 (defcustom smtp-use-starttls-ignore-error nil
102 "If non-nil, do not use STARTTLS if STARTTLS is not available."
104 :group 'smtp-extensions)
106 (defcustom smtp-starttls-program "starttls"
107 "The program to run in a subprocess to open an TLSv1 connection."
108 :group 'smtp-extensions)
110 (defcustom smtp-starttls-extra-args nil
111 "Extra arguments to `starttls-program'"
112 :group 'smtp-extensions)
114 (defcustom smtp-use-sasl nil
115 "If non-nil, use SMTP Authentication (RFC2554) if available."
117 :group 'smtp-extensions)
119 (defcustom smtp-sasl-user-name (user-login-name)
120 "Identification to be used for authorization."
122 :group 'smtp-extensions)
124 (defcustom smtp-sasl-properties nil
125 "Properties set to SASL client."
127 :group 'smtp-extensions)
129 (defcustom smtp-sasl-mechanisms nil
130 "List of authentication mechanisms."
131 :type '(repeat string)
132 :group 'smtp-extensions)
134 (defcustom smtp-progress-message-format nil
135 "Format string used to show progress message while sending mails.
136 It allows the following special format specifiers:
138 %b means show the number of bytes which has been sent
139 and the total bytes of a mail.
140 %k means show the number of kilobytes which has been sent
141 and the total kilobytes of a mail.
142 %l means show the number of lines which has been sent
143 and the total lines of a mail.
145 For instance, the value \"Sending (%k)...\" shows like
146 \"Sending (45k/123k)...\" in the echo area."
147 :type '(radio (string :format "%v\n" :size 0 :value "Sending (%k)...")
148 (const :tag "Don't show progress message" nil))
151 (defcustom smtp-debug nil
152 "*If non-nil, smtp debug info printout into messages."
156 (defvar sasl-mechanisms)
159 (defvar smtp-open-connection-function #'open-network-stream
160 "*Function used for connecting to a SMTP server.
161 The function will be called with the same four arguments as
162 `open-network-stream' and should return a process object.
165 \(setq smtp-open-connection-function
166 #'(lambda (name buffer host service)
167 (let ((process-connection-type nil))
168 (start-process name buffer \"ssh\" \"-C\" host
169 \"nc\" host service))))
171 It connects to a SMTP server using \"ssh\" before actually connecting
172 to the SMTP port. Where the command \"nc\" is the netcat executable;
173 see http://www.atstake.com/research/tools/index.html#network_utilities
174 for details. In addition, you will have to modify the value for
175 `smtp-end-of-line' to \"\\n\" if you use \"telnet\" instead of \"nc\".")
177 (defvar smtp-read-point nil)
179 (defvar smtp-connection-alist nil)
181 (defvar smtp-submit-package-function #'smtp-submit-package)
183 (defvar smtp-end-of-line "\r\n"
184 "*String to use as end-of-line marker when talking to a SMTP server.
185 This is \"\\r\\n\" by default, but it may have to be \"\\n\" when using a non
186 native connection function. See also `smtp-open-connection-function'.")
189 ;;; A package contains a mail message, an envelope sender address,
190 ;;; and one or more envelope recipient addresses. In ESMTP model
191 ;;; the current sending package should be guaranteed to be accessible
192 ;;; anywhere from the hook methods (or SMTP commands).
195 (luna-define-class smtp-package ()
200 (luna-define-internal-accessors 'smtp-package))
202 (defun smtp-make-package (sender recipients buffer)
203 "Create a new package structure.
204 A package is a unit of SMTP message
205 SENDER specifies the package sender, a string.
206 RECIPIENTS is a list of recipients.
207 BUFFER may be a buffer or a buffer name which contains mail message."
208 (luna-make-entity 'smtp-package :sender sender :recipients recipients :buffer buffer))
210 (defun smtp-package-buffer-internal-size (package)
211 "Return the size of PACKAGE, an integer."
213 (set-buffer (smtp-package-buffer-internal package))
216 ;; Add one byte for each change-of-line
217 ;; because or CR-LF representation:
218 (count-lines (point-min) (point-max))
219 ;; For some reason, an empty line is
220 ;; added to the message. Maybe this
221 ;; is a bug, but it can't hurt to add
222 ;; those two bytes anyway:
224 (goto-char (point-min))
225 (while (re-search-forward "^\\." nil t)
226 (setq size (1+ size)))
229 ;;; @ SMTP connection
230 ;;; We should consider the function `open-network-stream' is a emulation
231 ;;; for another network stream. They are likely to be implemented with an
232 ;;; external program and the function `process-contact' returns the
233 ;;; process id instead of `(HOST SERVICE)' pair.
236 (luna-define-class smtp-connection ()
244 (luna-define-internal-accessors 'smtp-connection))
246 (defun smtp-make-connection (process server service)
247 "Create a new connection structure.
248 PROCESS is an internal subprocess-object. SERVER is name of the host
249 to connect to. SERVICE is name of the service desired."
250 (luna-make-entity 'smtp-connection :process process :server server :service service))
252 (luna-define-generic smtp-connection-opened (connection)
253 "Say whether the CONNECTION to server has been opened.")
255 (luna-define-generic smtp-close-connection (connection)
256 "Close the CONNECTION to server.")
258 (luna-define-method smtp-connection-opened ((connection smtp-connection))
259 (let ((process (smtp-connection-process-internal connection)))
260 (if (memq (process-status process) '(open run))
263 (luna-define-method smtp-close-connection ((connection smtp-connection))
264 (let ((process (smtp-connection-process-internal connection)))
265 (delete-process process)))
267 (defun smtp-make-fqdn ()
268 "Return user's fully qualified domain name."
271 (let ((system-name (system-name)))
274 (concat system-name "." smtp-local-domain))
275 ((string-match "[^.]\\.[^.]" system-name)
278 (error "Cannot generate valid FQDN"))))))
280 (defun smtp-find-connection (buffer)
281 "Find the connection delivering to BUFFER."
282 (let ((entry (assq buffer smtp-connection-alist))
285 (setq connection (nth 1 entry))
286 (if (smtp-connection-opened connection)
288 (setq smtp-connection-alist
289 (delq entry smtp-connection-alist))
293 (autoload 'starttls-open-stream "starttls")
294 (autoload 'starttls-negotiate "starttls"))
296 (defun smtp-open-connection (buffer server service)
297 "Open a SMTP connection for a service to a host.
298 Return a newly allocated connection-object.
299 BUFFER is the buffer to associate with the connection. SERVER is name
300 of the host to connect to. SERVICE is name of the service desired."
302 (binary-funcall smtp-open-connection-function
303 "SMTP" buffer server service))
306 (setq connection (smtp-make-connection process server service))
307 (set-process-filter process 'smtp-process-filter)
308 (setq smtp-connection-alist
309 (cons (list buffer connection)
310 smtp-connection-alist))
314 (autoload 'dig-invoke "dig")
315 (autoload 'dig-extract-rr "dig"))
317 (defun smtp-find-mx (domain &optional doerror)
319 ;; dig.el resolves only primally MX.
320 (cond ((setq server (smtp-dig domain "MX"))
321 (progn (string-match " \\([^ ]*\\)$" server)
322 (match-string 1 server)))
323 ((smtp-dig domain "A")
327 (error (format "SMTP cannot resolve %s" domain)))))))
329 (defun smtp-dig (domain type)
332 (setq dig-buf (dig-invoke domain type)))
334 (dig-extract-rr domain type)
335 (kill-buffer dig-buf))))
337 (defun smtp-find-server (recipients)
340 (mapcar (lambda (recipient)
342 (if (and (string-match "@\\([^\t\n ]*\\)" recipient)
345 (match-string 1 recipient))))
346 (cons server (list recipient))
347 (error (format "cannot find server for %s." recipient)))))
350 (while (setq rets (pop rec))
351 (if (setq ret (assoc (car rets) rec))
353 (append (cdr ret) (cdr rets)))
355 (append rlist (list rets)))))
359 (defun smtp-via-smtp (sender recipients buffer)
360 "Like `smtp-send-buffer', but sucks in any errors."
363 (smtp-send-buffer sender recipients buffer)
367 (make-obsolete 'smtp-via-smtp "It's old API.")
370 (defun smtp-send-buffer (sender recipients buffer)
372 SENDER is an envelope sender address.
373 RECIPIENTS is a list of envelope recipient addresses.
374 BUFFER may be a buffer or a buffer name which contains mail message."
375 (if smtp-send-by-myself
376 (smtp-send-buffer-by-myself sender recipients buffer)
378 (if (functionp smtp-server)
379 (funcall smtp-server sender recipients)
381 (error "`smtp-server' not defined"))))
383 (smtp-make-package sender recipients buffer))
384 (starttls-program smtp-starttls-program)
385 (starttls-extra-args smtp-starttls-extra-args)
386 (smtp-open-connection-function
387 (if smtp-use-starttls
388 #'starttls-open-stream
389 smtp-open-connection-function)))
393 (format "*trace of SMTP session to %s*" server)))
395 (buffer-disable-undo)
396 (unless (smtp-find-connection (current-buffer))
397 (smtp-open-connection (current-buffer) server smtp-service))
398 (make-local-variable 'smtp-read-point)
399 (setq smtp-read-point (point-min))
400 (funcall smtp-submit-package-function package)))))
402 (defun smtp-submit-package (package)
405 (smtp-primitive-greeting package)
407 (smtp-primitive-ehlo package)
409 (smtp-primitive-helo package)))
410 (if smtp-use-starttls
412 (smtp-connection-extensions-internal
413 (smtp-find-connection (current-buffer))))
415 (smtp-primitive-starttls package)
416 (smtp-primitive-ehlo package))
417 (unless smtp-use-starttls-ignore-error
418 (error "STARTTLS is not supported on this server"))))
420 (smtp-primitive-auth package))
421 (smtp-primitive-mailfrom package)
422 (smtp-primitive-rcptto package)
423 (smtp-primitive-data package))
424 (let ((connection (smtp-find-connection (current-buffer))))
425 (when (smtp-connection-opened connection)
426 (smtp-primitive-quit package)
427 (smtp-close-connection connection)))))
429 (defun smtp-send-buffer-by-myself (sender recipients buffer)
430 "Send a message by myself.
431 SENDER is an envelope sender address.
432 RECIPIENTS is a list of envelope recipient addresses.
433 BUFFER may be a buffer or a buffer name which contains mail message."
435 (smtp-find-server recipients))
436 (smtp-open-connection-function
437 (if smtp-use-starttls
438 #'starttls-open-stream
439 smtp-open-connection-function))
442 (setq server (caar servers))
443 (setq recipients (cdar servers))
444 (if (not (and server recipients))
445 ;; MAILER-DAEMON is required. :)
446 (error (format "Cannot send <%s>"
447 (mapconcat 'concat recipients ">,<"))))
449 (smtp-make-package sender recipients buffer))
453 (format "*trace of SMTP session to %s*" server)))
455 (buffer-disable-undo)
456 (unless (smtp-find-connection (current-buffer))
457 (smtp-open-connection (current-buffer) server smtp-service))
458 (make-local-variable 'smtp-read-point)
459 (setq smtp-read-point (point-min))
460 (let ((smtp-use-sasl nil)
461 (smtp-use-starttls-ignore-error t))
462 (funcall smtp-submit-package-function package)))
463 (setq servers (cdr servers)))))
465 ;;; @ hook methods for `smtp-submit-package'
468 (defun smtp-primitive-greeting (package)
470 (smtp-find-connection (current-buffer)))
472 (smtp-read-response connection)))
473 (if (/= (car response) 220)
474 (smtp-response-error response))))
476 (defun smtp-primitive-ehlo (package)
478 (smtp-find-connection (current-buffer)))
480 (smtp-send-command connection (format "EHLO %s" (smtp-make-fqdn)))
481 (setq response (smtp-read-response connection))
482 (if (/= (car response) 250)
483 (smtp-response-error response))
484 (smtp-connection-set-extensions-internal
488 (split-string extension)))
490 (car (read-from-string
491 (downcase (car extensions)))))
495 (defun smtp-primitive-helo (package)
497 (smtp-find-connection (current-buffer)))
499 (smtp-send-command connection (format "HELO %s" (smtp-make-fqdn)))
500 (setq response (smtp-read-response connection))
501 (if (/= (car response) 250)
502 (smtp-response-error response))))
504 (defun smtp-primitive-auth (package)
506 (smtp-find-connection (current-buffer)))
508 (cdr (assq 'auth (smtp-connection-extensions-internal connection))))
510 (or smtp-sasl-mechanisms sasl-mechanisms))
512 (sasl-find-mechanism mechanisms))
518 (error "No authentication mechanism available"))
519 (setq client (sasl-make-client mechanism smtp-sasl-user-name "smtp"
520 (smtp-connection-server-internal connection)))
521 (if smtp-sasl-properties
522 (sasl-client-set-properties client smtp-sasl-properties))
523 (setq name (sasl-mechanism-name mechanism)
524 ;; Retrieve the initial response
525 step (sasl-next-step client nil))
528 (if (sasl-step-data step)
529 (format "AUTH %s %s" name (base64-encode-string (sasl-step-data step) t))
530 (format "AUTH %s" name)))
533 (setq response (smtp-read-response connection))
534 (when (= (car response) 235)
535 ;; The authentication process is finished.
536 (setq step (sasl-next-step client step))
539 (smtp-response-error response)) ;Bogus server?
540 (if (/= (car response) 334)
541 (smtp-response-error response))
542 (sasl-step-set-data step (base64-decode-string (nth 1 response)))
543 (setq step (sasl-next-step client step))
546 (if (sasl-step-data step)
547 (base64-encode-string (sasl-step-data step) t)
549 ;;; (smtp-connection-set-encoder-internal
550 ;;; connection (sasl-client-encoder client))
551 ;;; (smtp-connection-set-decoder-internal
552 ;;; connection (sasl-client-decoder client))
555 (defun smtp-primitive-starttls (package)
557 (smtp-find-connection (current-buffer)))
559 ;; STARTTLS --- begin a TLS negotiation (RFC 2595)
560 (smtp-send-command connection "STARTTLS")
561 (setq response (smtp-read-response connection))
562 (if (/= (car response) 220)
563 (smtp-response-error response))
564 (starttls-negotiate (smtp-connection-process-internal connection))))
566 (defun smtp-primitive-mailfrom (package)
568 (smtp-find-connection (current-buffer)))
570 (smtp-connection-extensions-internal
573 (smtp-package-sender-internal package))
576 ;; SIZE --- Message Size Declaration (RFC1870)
577 (if (and smtp-use-size
578 (assq 'size extensions))
579 (setq extension (format "SIZE=%d" (smtp-package-buffer-internal-size package))))
580 ;; 8BITMIME --- 8bit-MIMEtransport (RFC1652)
581 (if (and smtp-use-8bitmime
582 (assq '8bitmime extensions))
583 (setq extension (concat extension " BODY=8BITMIME")))
587 (format "MAIL FROM:<%s> %s" sender extension)
588 (format "MAIL FROM:<%s>" sender)))
589 (setq response (smtp-read-response connection))
590 (if (/= (car response) 250)
591 (smtp-response-error response))))
593 (defun smtp-primitive-rcptto (package)
595 (smtp-find-connection (current-buffer)))
597 (smtp-package-recipients-internal package))
601 connection (format "RCPT TO:<%s>" (pop recipients)))
602 (setq response (smtp-read-response connection))
603 (unless (memq (car response) '(250 251))
604 (smtp-response-error response)))))
606 (defun smtp-primitive-data (package)
608 (smtp-find-connection (current-buffer)))
610 (smtp-send-command connection "DATA")
611 (setq response (smtp-read-response connection))
612 (if (/= (car response) 354)
613 (smtp-response-error response))
615 (set-buffer (smtp-package-buffer-internal package))
616 (setq def (smtp-parse-progress-message-format))
617 (goto-char (point-min))
620 connection (buffer-substring (point) (progn (end-of-line)(point))))
621 (beginning-of-line 2)
622 (setq prev (smtp-show-progress-message def prev))))
623 (smtp-send-command connection ".")
624 (setq response (smtp-read-response connection))
625 (if (/= (car response) 250)
626 (smtp-response-error response))))
628 (defun smtp-primitive-quit (package)
630 (smtp-find-connection (current-buffer)))
632 (smtp-send-command connection "QUIT")
633 (setq response (smtp-read-response connection))
634 (if (/= (car response) 221)
635 (smtp-response-error response))))
637 ;;; @ low level process manipulating function
639 (defun smtp-process-filter (process output)
641 (set-buffer (process-buffer process))
642 (goto-char (point-max))
645 (put 'smtp-error 'error-message "SMTP error")
646 (put 'smtp-error 'error-conditions '(smtp-error error))
648 (put 'smtp-response-error 'error-message "SMTP response error")
649 (put 'smtp-response-error 'error-conditions '(smtp-response-error smtp-error error))
651 (defun smtp-response-error (response)
652 (signal 'smtp-response-error response))
654 (defun smtp-read-response (connection)
656 (smtp-connection-decoder-internal connection))
657 (response-continue t)
659 (while response-continue
660 (goto-char smtp-read-point)
661 (while (not (re-search-forward "\r?\n" nil t))
662 (unless (smtp-connection-opened connection)
663 (signal 'smtp-error "Connection closed"))
664 (accept-process-output (smtp-connection-process-internal connection))
665 (goto-char smtp-read-point))
666 (let ((bol smtp-read-point)
667 (eol (match-beginning 0))
670 (let ((string (buffer-substring bol eol)))
671 (delete-region bol (point))
672 (insert (funcall decoder string))
674 (insert smtp-end-of-line)))
675 (setq smtp-read-point (point))
677 (if (not (looking-at "[1-5][0-9][0-9]\\([ -]\\)"))
679 (message "Invalid response: %s" (buffer-substring bol eol)))
680 (when (string= (match-string 1) " ")
681 (setq reply-code (read (point-marker))))
684 (list (buffer-substring (match-end 0) eol))))
686 (setq response (cons reply-code response)
687 response-continue nil)))))
690 (defun smtp-send-command (connection command)
693 (smtp-connection-process-internal connection))
695 (smtp-connection-encoder-internal connection)))
696 (set-buffer (process-buffer process))
697 (goto-char (point-max))
698 (setq command (concat command smtp-end-of-line))
700 (setq smtp-read-point (point))
702 (setq command (funcall encoder command)))
703 (process-send-string process command))))
705 (defun smtp-send-data (connection data)
707 (smtp-connection-process-internal connection))
709 (smtp-connection-encoder-internal connection)))
710 ;; Escape "." at start of a line.
711 (if (eq (string-to-char data) ?.)
712 (setq data (concat "." data smtp-end-of-line))
713 (setq data (concat data smtp-end-of-line)))
715 (setq data (funcall encoder data)))
716 (process-send-string process data)))
718 (defun smtp-deduce-address-list (smtp-text-buffer header-start header-end)
719 "Get address list suitable for smtp RCPT TO:<address>."
720 (let ((simple-address-list "")
724 (smtp-address-buffer (generate-new-buffer " *smtp-mail*")))
728 (set-buffer smtp-address-buffer)
729 (setq case-fold-search t)
731 (insert (save-excursion
732 (set-buffer smtp-text-buffer)
733 (buffer-substring-no-properties header-start header-end)))
734 (goto-char (point-min))
735 ;; RESENT-* fields should stop processing of regular fields.
737 (if (re-search-forward "^RESENT-TO:" header-end t)
739 "^\\(RESENT-TO:\\|RESENT-CC:\\|RESENT-BCC:\\)")
740 (setq addr-regexp "^\\(TO:\\|CC:\\|BCC:\\)")))
742 (while (re-search-forward addr-regexp header-end t)
744 (setq this-line (match-beginning 0))
746 ;; get any continuation lines.
747 (while (and (looking-at "^[ \t]+") (< (point) header-end))
749 (setq this-line-end (point-marker))
750 (setq simple-address-list
751 (concat simple-address-list " "
752 (mail-strip-quoted-names
753 (buffer-substring this-line this-line-end)))))
755 (insert " " simple-address-list "\n")
757 (subst-char-in-region (point-min) (point-max) 10 ? t)
759 (subst-char-in-region (point-min) (point-max) ?, ? t)
761 (subst-char-in-region (point-min) (point-max) 9 ? t)
763 (goto-char (point-min))
764 ;; tidyness in case hook is not robust when it looks at this
765 (while (re-search-forward "[ \t]+" header-end t) (replace-match " "))
767 (goto-char (point-min))
768 (let (recipient-address-list)
769 (while (re-search-forward " \\([^ ]+\\) " (point-max) t)
771 (setq recipient-address-list
772 (cons (buffer-substring (match-beginning 1) (match-end 1))
773 recipient-address-list)))
774 recipient-address-list))
775 (kill-buffer smtp-address-buffer))))
777 ;;; @ functions used to show progress message
779 (defun smtp-parse-progress-message-format ()
780 "Parse the `smtp-progress-message-format' variable.
781 Return nil, or a cons of an ordinary format string and a type including
782 nil, the symbols `b', `k' and `l'."
783 (when smtp-progress-message-format
784 (let ((format smtp-progress-message-format)
787 (while (string-match "%\\([bkl]\\)\\|%\\([^%bkl]\\|\\'\\)" format index)
790 (setq index (match-end 0)
791 type (intern (match-string 1 format))
792 format (replace-match
795 (number-to-string (buffer-size))))
797 (if (>= (buffer-size) 512)
800 (/ (+ (buffer-size) 512) 1024))
804 (number-to-string (buffer-size)))))
808 (count-lines (point-min)
811 (setq index (1+ (match-end 0))
812 format (replace-match "%\\&" nil nil format))))
813 (cons format type))))
815 (defun smtp-show-progress-message (def prev)
816 "Show progress message while sending mails.
817 DEF is a cons cell which is pre-computed by the
818 `smtp-parse-progress-message-format' function or nil.
819 PREV is a number shown last time or nil.
820 Return a number computed this time."
822 (let* ((fmt (car def))
824 (value (cond ((eq type 'b)
825 (- (point) (point-min)))
827 (/ (- (point) (point-min) -512) 1024))
829 (count-lines (point-min) (point)))))
835 (cond ((featurep 'xemacs)
836 (display-message 'no-log (if value
842 (message "%s" fmt))))
847 ;;; smtp.el ends here