(smtpmail-via-smtp): Parse out the first word
[bpt/emacs.git] / lisp / mail / smtpmail.el
1 ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
2
3 ;; Copyright (C) 1995, 1996 Free Software Foundation, Inc.
4
5 ;; Author: Tomoji Kagatani <kagatani@rbc.ncl.omron.co.jp>
6 ;; Maintainer: Brian D. Carlstrom <bdc@ai.mit.edu>
7 ;; ESMTP support: Simon Leinen <simon@switch.ch>
8 ;; Keywords: mail
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
26
27 ;;; Commentary:
28
29 ;; Send Mail to smtp host from smtpmail temp buffer.
30
31 ;; Please add these lines in your .emacs(_emacs) or use customize.
32 ;;
33 ;;(setq send-mail-function 'smtpmail-send-it) ; if you use `mail'
34 ;;(setq message-send-mail-function 'smtpmail-send-it) ; if you use `message'
35 ;;(setq smtpmail-default-smtp-server "YOUR SMTP HOST")
36 ;;(setq smtpmail-local-domain "YOUR DOMAIN NAME")
37 ;;(setq smtpmail-debug-info t) ; only to debug problems
38
39 ;; To queue mail, set smtpmail-queue-mail to t and use
40 ;; smtpmail-send-queued-mail to send.
41
42
43 ;;; Code:
44
45 (require 'sendmail)
46 (require 'time-stamp)
47
48 ;;;
49 (defgroup smtpmail nil
50 "SMTP protocol for sending mail."
51 :group 'mail)
52
53
54 (defcustom smtpmail-default-smtp-server nil
55 "*Specify default SMTP server."
56 :type '(choice (const nil) string)
57 :group 'smtpmail)
58
59 (defcustom smtpmail-smtp-server
60 (or (getenv "SMTPSERVER") smtpmail-default-smtp-server)
61 "*The name of the host running SMTP server."
62 :type '(choice (const nil) string)
63 :group 'smtpmail)
64
65 (defcustom smtpmail-smtp-service 25
66 "*SMTP service port number. smtp or 25 ."
67 :type 'integer
68 :group 'smtpmail)
69
70 (defcustom smtpmail-local-domain nil
71 "*Local domain name without a host name.
72 If the function (system-name) returns the full internet address,
73 don't define this value."
74 :type '(choice (const nil) string)
75 :group 'smtpmail)
76
77 (defcustom smtpmail-debug-info nil
78 "*smtpmail debug info printout. messages and process buffer."
79 :type 'boolean
80 :group 'smtpmail)
81
82 (defcustom smtpmail-code-conv-from nil ;; *junet*
83 "*smtpmail code convert from this code to *internal*..for tiny-mime.."
84 :type 'boolean
85 :group 'smtpmail)
86
87 (defcustom smtpmail-queue-mail nil
88 "*Specify if mail is queued (if t) or sent immediately (if nil).
89 If queued, it is stored in the directory `smtpmail-queue-dir'
90 and sent with `smtpmail-send-queued-mail'."
91 :type 'boolean
92 :group 'smtpmail)
93
94 (defcustom smtpmail-queue-dir "~/Mail/queued-mail/"
95 "*Directory where `smtpmail.el' stores queued mail."
96 :type 'directory
97 :group 'smtpmail)
98
99 (defvar smtpmail-queue-index-file "index"
100 "File name of queued mail index,
101 This is relative to `smtpmail-queue-dir'.")
102
103 (defvar smtpmail-queue-index (concat smtpmail-queue-dir
104 smtpmail-queue-index-file))
105
106 ;;;
107 ;;;
108 ;;;
109
110 ;;;###autoload
111 (defun smtpmail-send-it ()
112 (require 'mail-utils)
113 (let ((errbuf (if mail-interactive
114 (generate-new-buffer " smtpmail errors")
115 0))
116 (tembuf (generate-new-buffer " smtpmail temp"))
117 (case-fold-search nil)
118 delimline
119 (mailbuf (current-buffer)))
120 (unwind-protect
121 (save-excursion
122 (set-buffer tembuf)
123 (erase-buffer)
124 (insert-buffer-substring mailbuf)
125 (goto-char (point-max))
126 ;; require one newline at the end.
127 (or (= (preceding-char) ?\n)
128 (insert ?\n))
129 ;; Change header-delimiter to be what sendmail expects.
130 (mail-sendmail-undelimit-header)
131 (setq delimline (point-marker))
132 ;; (sendmail-synch-aliases)
133 (if mail-aliases
134 (expand-mail-aliases (point-min) delimline))
135 (goto-char (point-min))
136 ;; ignore any blank lines in the header
137 (while (and (re-search-forward "\n\n\n*" delimline t)
138 (< (point) delimline))
139 (replace-match "\n"))
140 (let ((case-fold-search t))
141 ;; We used to process Resent-... headers here,
142 ;; but it was not done properly, and the job
143 ;; is done correctly in smtpmail-deduce-address-list.
144 ;; Don't send out a blank subject line
145 (goto-char (point-min))
146 (if (re-search-forward "^Subject:\\([ \t]*\n\\)+\\b" delimline t)
147 (replace-match "")
148 ;; This one matches a Subject just before the header delimiter.
149 (if (and (re-search-forward "^Subject:\\([ \t]*\n\\)+" delimline t)
150 (= (match-end 0) delimline))
151 (replace-match "")))
152 ;; Put the "From:" field in unless for some odd reason
153 ;; they put one in themselves.
154 (goto-char (point-min))
155 (if (not (re-search-forward "^From:" delimline t))
156 (let* ((login user-mail-address)
157 (fullname (user-full-name)))
158 (cond ((eq mail-from-style 'angles)
159 (insert "From: " fullname)
160 (let ((fullname-start (+ (point-min) 6))
161 (fullname-end (point-marker)))
162 (goto-char fullname-start)
163 ;; Look for a character that cannot appear unquoted
164 ;; according to RFC 822.
165 (if (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]"
166 fullname-end 1)
167 (progn
168 ;; Quote fullname, escaping specials.
169 (goto-char fullname-start)
170 (insert "\"")
171 (while (re-search-forward "[\"\\]"
172 fullname-end 1)
173 (replace-match "\\\\\\&" t))
174 (insert "\""))))
175 (insert " <" login ">\n"))
176 ((eq mail-from-style 'parens)
177 (insert "From: " login " (")
178 (let ((fullname-start (point)))
179 (insert fullname)
180 (let ((fullname-end (point-marker)))
181 (goto-char fullname-start)
182 ;; RFC 822 says \ and nonmatching parentheses
183 ;; must be escaped in comments.
184 ;; Escape every instance of ()\ ...
185 (while (re-search-forward "[()\\]" fullname-end 1)
186 (replace-match "\\\\\\&" t))
187 ;; ... then undo escaping of matching parentheses,
188 ;; including matching nested parentheses.
189 (goto-char fullname-start)
190 (while (re-search-forward
191 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)"
192 fullname-end 1)
193 (replace-match "\\1(\\3)" t)
194 (goto-char fullname-start))))
195 (insert ")\n"))
196 ((null mail-from-style)
197 (insert "From: " login "\n")))))
198 ;; Insert an extra newline if we need it to work around
199 ;; Sun's bug that swallows newlines.
200 (goto-char (1+ delimline))
201 (if (eval mail-mailer-swallows-blank-line)
202 (newline))
203 ;; Find and handle any FCC fields.
204 (goto-char (point-min))
205 (if (re-search-forward "^FCC:" delimline t)
206 (mail-do-fcc delimline))
207 (if mail-interactive
208 (save-excursion
209 (set-buffer errbuf)
210 (erase-buffer))))
211 ;;
212 ;;
213 ;;
214 (setq smtpmail-address-buffer (generate-new-buffer "*smtp-mail*"))
215 (setq smtpmail-recipient-address-list
216 (smtpmail-deduce-address-list tembuf (point-min) delimline))
217 (kill-buffer smtpmail-address-buffer)
218
219 (smtpmail-do-bcc delimline)
220 ; Send or queue
221 (if (not smtpmail-queue-mail)
222 (if (not (null smtpmail-recipient-address-list))
223 (if (not (smtpmail-via-smtp
224 smtpmail-recipient-address-list tembuf))
225 (error "Sending failed; SMTP protocol error"))
226 (error "Sending failed; no recipients"))
227 (let* ((file-data (concat
228 smtpmail-queue-dir
229 (concat (time-stamp-yyyy-mm-dd)
230 "_" (time-stamp-hh:mm:ss))))
231 (file-elisp (concat file-data ".el"))
232 (buffer-data (create-file-buffer file-data))
233 (buffer-elisp (create-file-buffer file-elisp))
234 (buffer-scratch "*queue-mail*"))
235 (save-excursion
236 (set-buffer buffer-data)
237 (erase-buffer)
238 (insert-buffer tembuf)
239 (write-file file-data)
240 (set-buffer buffer-elisp)
241 (erase-buffer)
242 (insert (concat
243 "(setq smtpmail-recipient-address-list '"
244 (prin1-to-string smtpmail-recipient-address-list)
245 ")\n"))
246 (write-file file-elisp)
247 (set-buffer (generate-new-buffer buffer-scratch))
248 (insert (concat file-data "\n"))
249 (append-to-file (point-min)
250 (point-max)
251 smtpmail-queue-index)
252 )
253 (kill-buffer buffer-scratch)
254 (kill-buffer buffer-data)
255 (kill-buffer buffer-elisp))))
256 (kill-buffer tembuf)
257 (if (bufferp errbuf)
258 (kill-buffer errbuf)))))
259
260 (defun smtpmail-send-queued-mail ()
261 "Send mail that was queued as a result of setting `smtpmail-queue-mail'."
262 (interactive)
263 ;;; Get index, get first mail, send it, get second mail, etc...
264 (let ((buffer-index (find-file-noselect smtpmail-queue-index))
265 (file-msg "")
266 (tembuf nil))
267 (save-excursion
268 (set-buffer buffer-index)
269 (beginning-of-buffer)
270 (while (not (eobp))
271 (setq file-msg (buffer-substring (point) (save-excursion
272 (end-of-line)
273 (point))))
274 (load file-msg)
275 (setq tembuf (find-file-noselect file-msg))
276 (if (not (null smtpmail-recipient-address-list))
277 (if (not (smtpmail-via-smtp smtpmail-recipient-address-list
278 tembuf))
279 (error "Sending failed; SMTP protocol error"))
280 (error "Sending failed; no recipients"))
281 (delete-file file-msg)
282 (delete-file (concat file-msg ".el"))
283 (kill-buffer tembuf)
284 (kill-line 1))
285 (set-buffer buffer-index)
286 (save-buffer smtpmail-queue-index)
287 (kill-buffer buffer-index)
288 )))
289
290 ;(defun smtpmail-via-smtp (host,port,sender,destination,smtpmail-text-buffer)
291
292 (defun smtpmail-fqdn ()
293 (if smtpmail-local-domain
294 (concat (system-name) "." smtpmail-local-domain)
295 (system-name)))
296
297 (defun smtpmail-via-smtp (recipient smtpmail-text-buffer)
298 (let ((process nil)
299 (host (or smtpmail-smtp-server
300 (error "`smtpmail-smtp-server' not defined")))
301 (port smtpmail-smtp-service)
302 response-code
303 greeting
304 process-buffer
305 (supported-extensions '()))
306 (unwind-protect
307 (catch 'done
308 ;; get or create the trace buffer
309 (setq process-buffer
310 (get-buffer-create (format "*trace of SMTP session to %s*" host)))
311
312 ;; clear the trace buffer of old output
313 (save-excursion
314 (set-buffer process-buffer)
315 (erase-buffer))
316
317 ;; open the connection to the server
318 (setq process (open-network-stream "SMTP" process-buffer host port))
319 (and (null process) (throw 'done nil))
320
321 ;; set the send-filter
322 (set-process-filter process 'smtpmail-process-filter)
323
324 (save-excursion
325 (set-buffer process-buffer)
326 (set-buffer-process-coding-system 'raw-text-unix 'raw-text-unix)
327 (make-local-variable 'smtpmail-read-point)
328 (setq smtpmail-read-point (point-min))
329
330
331 (if (or (null (car (setq greeting (smtpmail-read-response process))))
332 (not (integerp (car greeting)))
333 (>= (car greeting) 400))
334 (throw 'done nil)
335 )
336
337 ;; EHLO
338 (smtpmail-send-command process (format "EHLO %s" (smtpmail-fqdn)))
339
340 (if (or (null (car (setq response-code (smtpmail-read-response process))))
341 (not (integerp (car response-code)))
342 (>= (car response-code) 400))
343 (progn
344 ;; HELO
345 (smtpmail-send-command process (format "HELO %s" (smtpmail-fqdn)))
346
347 (if (or (null (car (setq response-code (smtpmail-read-response process))))
348 (not (integerp (car response-code)))
349 (>= (car response-code) 400))
350 (throw 'done nil)))
351 (let ((extension-lines (cdr (cdr response-code))))
352 (while extension-lines
353 (let ((name (intern (downcase (car (split-string (substring (car extension-lines) 4) "[ ]"))))))
354 (and name
355 (cond ((memq name '(verb xvrb 8bitmime onex xone
356 expn size dsn etrn
357 help xusr))
358 (setq supported-extensions
359 (cons name supported-extensions)))
360 (t (message "unknown extension %s"
361 name)))))
362 (setq extension-lines (cdr extension-lines)))))
363
364 (if (or (member 'onex supported-extensions)
365 (member 'xone supported-extensions))
366 (progn
367 (smtpmail-send-command process (format "ONEX"))
368 (if (or (null (car (setq response-code (smtpmail-read-response process))))
369 (not (integerp (car response-code)))
370 (>= (car response-code) 400))
371 (throw 'done nil))))
372
373 (if (and smtpmail-debug-info
374 (or (member 'verb supported-extensions)
375 (member 'xvrb supported-extensions)))
376 (progn
377 (smtpmail-send-command process (format "VERB"))
378 (if (or (null (car (setq response-code (smtpmail-read-response process))))
379 (not (integerp (car response-code)))
380 (>= (car response-code) 400))
381 (throw 'done nil))))
382
383 (if (member 'xusr supported-extensions)
384 (progn
385 (smtpmail-send-command process (format "XUSR"))
386 (if (or (null (car (setq response-code (smtpmail-read-response process))))
387 (not (integerp (car response-code)))
388 (>= (car response-code) 400))
389 (throw 'done nil))))
390
391 ;; MAIL FROM: <sender>
392 (let ((size-part
393 (if (member 'size supported-extensions)
394 (format " SIZE=%d"
395 (save-excursion
396 (set-buffer smtpmail-text-buffer)
397 ;; size estimate:
398 (+ (- (point-max) (point-min))
399 ;; Add one byte for each change-of-line
400 ;; because or CR-LF representation:
401 (count-lines (point-min) (point-max))
402 ;; For some reason, an empty line is
403 ;; added to the message. Maybe this
404 ;; is a bug, but it can't hurt to add
405 ;; those two bytes anyway:
406 2)))
407 ""))
408 (body-part
409 (if (member '8bitmime supported-extensions)
410 ;; FIXME:
411 ;; Code should be added here that transforms
412 ;; the contents of the message buffer into
413 ;; something the receiving SMTP can handle.
414 ;; For a receiver that supports 8BITMIME, this
415 ;; may mean converting BINARY to BASE64, or
416 ;; adding Content-Transfer-Encoding and the
417 ;; other MIME headers. The code should also
418 ;; return an indication of what encoding the
419 ;; message buffer is now, i.e. ASCII or
420 ;; 8BITMIME.
421 (if nil
422 " BODY=8BITMIME"
423 "")
424 "")))
425 ; (smtpmail-send-command process (format "MAIL FROM:%s@%s" (user-login-name) (smtpmail-fqdn)))
426 (smtpmail-send-command process (format "MAIL FROM: <%s>%s%s"
427 user-mail-address
428 size-part
429 body-part))
430
431 (if (or (null (car (setq response-code (smtpmail-read-response process))))
432 (not (integerp (car response-code)))
433 (>= (car response-code) 400))
434 (throw 'done nil)
435 ))
436
437 ;; RCPT TO: <recipient>
438 (let ((n 0))
439 (while (not (null (nth n recipient)))
440 (smtpmail-send-command process (format "RCPT TO: <%s>" (nth n recipient)))
441 (setq n (1+ n))
442
443 (setq response-code (smtpmail-read-response process))
444 (if (or (null (car response-code))
445 (not (integerp (car response-code)))
446 (>= (car response-code) 400))
447 (throw 'done nil)
448 )
449 ))
450
451 ;; DATA
452 (smtpmail-send-command process "DATA")
453
454 (if (or (null (car (setq response-code (smtpmail-read-response process))))
455 (not (integerp (car response-code)))
456 (>= (car response-code) 400))
457 (throw 'done nil)
458 )
459
460 ;; Mail contents
461 (smtpmail-send-data process smtpmail-text-buffer)
462
463 ;;DATA end "."
464 (smtpmail-send-command process ".")
465
466 (if (or (null (car (setq response-code (smtpmail-read-response process))))
467 (not (integerp (car response-code)))
468 (>= (car response-code) 400))
469 (throw 'done nil)
470 )
471
472 ;;QUIT
473 ; (smtpmail-send-command process "QUIT")
474 ; (and (null (car (smtpmail-read-response process)))
475 ; (throw 'done nil))
476 t ))
477 (if process
478 (save-excursion
479 (set-buffer (process-buffer process))
480 (smtpmail-send-command process "QUIT")
481 (smtpmail-read-response process)
482
483 ; (if (or (null (car (setq response-code (smtpmail-read-response process))))
484 ; (not (integerp (car response-code)))
485 ; (>= (car response-code) 400))
486 ; (throw 'done nil)
487 ; )
488 (delete-process process))))))
489
490
491 (defun smtpmail-process-filter (process output)
492 (save-excursion
493 (set-buffer (process-buffer process))
494 (goto-char (point-max))
495 (insert output)))
496
497 (defun smtpmail-read-response (process)
498 (let ((case-fold-search nil)
499 (response-strings nil)
500 (response-continue t)
501 (return-value '(nil ()))
502 match-end)
503
504 (while response-continue
505 (goto-char smtpmail-read-point)
506 (while (not (search-forward "\r\n" nil t))
507 (accept-process-output process)
508 (goto-char smtpmail-read-point))
509
510 (setq match-end (point))
511 (setq response-strings
512 (cons (buffer-substring smtpmail-read-point (- match-end 2))
513 response-strings))
514
515 (goto-char smtpmail-read-point)
516 (if (looking-at "[0-9]+ ")
517 (let ((begin (match-beginning 0))
518 (end (match-end 0)))
519 (if smtpmail-debug-info
520 (message "%s" (car response-strings)))
521
522 (setq smtpmail-read-point match-end)
523
524 ;; ignore lines that start with "0"
525 (if (looking-at "0[0-9]+ ")
526 nil
527 (setq response-continue nil)
528 (setq return-value
529 (cons (string-to-int
530 (buffer-substring begin end))
531 (nreverse response-strings)))))
532
533 (if (looking-at "[0-9]+-")
534 (progn (if smtpmail-debug-info
535 (message "%s" (car response-strings)))
536 (setq smtpmail-read-point match-end)
537 (setq response-continue t))
538 (progn
539 (setq smtpmail-read-point match-end)
540 (setq response-continue nil)
541 (setq return-value
542 (cons nil (nreverse response-strings)))
543 )
544 )))
545 (setq smtpmail-read-point match-end)
546 return-value))
547
548
549 (defun smtpmail-send-command (process command)
550 (goto-char (point-max))
551 (if (= (aref command 0) ?P)
552 (insert "PASS <omitted>\r\n")
553 (insert command "\r\n"))
554 (setq smtpmail-read-point (point))
555 (process-send-string process command)
556 (process-send-string process "\r\n"))
557
558 (defun smtpmail-send-data-1 (process data)
559 (goto-char (point-max))
560
561 (if (not (null smtpmail-code-conv-from))
562 (setq data (code-convert-string data smtpmail-code-conv-from *internal*)))
563
564 (if smtpmail-debug-info
565 (insert data "\r\n"))
566
567 (setq smtpmail-read-point (point))
568 ;; Escape "." at start of a line
569 (if (eq (string-to-char data) ?.)
570 (process-send-string process "."))
571 (process-send-string process data)
572 (process-send-string process "\r\n")
573 )
574
575 (defun smtpmail-send-data (process buffer)
576 (let
577 ((data-continue t)
578 (sending-data nil)
579 this-line
580 this-line-end)
581
582 (save-excursion
583 (set-buffer buffer)
584 (goto-char (point-min)))
585
586 (while data-continue
587 (save-excursion
588 (set-buffer buffer)
589 (beginning-of-line)
590 (setq this-line (point))
591 (end-of-line)
592 (setq this-line-end (point))
593 (setq sending-data nil)
594 (setq sending-data (buffer-substring this-line this-line-end))
595 (if (/= (forward-line 1) 0)
596 (setq data-continue nil)))
597
598 (smtpmail-send-data-1 process sending-data)
599 )
600 )
601 )
602
603
604 (defun smtpmail-deduce-address-list (smtpmail-text-buffer header-start header-end)
605 "Get address list suitable for smtp RCPT TO: <address>."
606 (require 'mail-utils) ;; pick up mail-strip-quoted-names
607 (let
608 ((case-fold-search t)
609 (simple-address-list "")
610 this-line
611 this-line-end
612 addr-regexp)
613
614 (unwind-protect
615 (save-excursion
616 ;;
617 (set-buffer smtpmail-address-buffer) (erase-buffer)
618 (insert-buffer-substring smtpmail-text-buffer header-start header-end)
619 (goto-char (point-min))
620 ;; RESENT-* fields should stop processing of regular fields.
621 (save-excursion
622 (if (re-search-forward "^Resent-\\(to\\|cc\\|bcc\\):" header-end t)
623 (setq addr-regexp "^Resent-\\(to\\|cc\\|bcc\\):")
624 (setq addr-regexp "^\\(To:\\|Cc:\\|Bcc:\\)")))
625
626 (while (re-search-forward addr-regexp header-end t)
627 (replace-match "")
628 (setq this-line (match-beginning 0))
629 (forward-line 1)
630 ;; get any continuation lines
631 (while (and (looking-at "^[ \t]+") (< (point) header-end))
632 (forward-line 1))
633 (setq this-line-end (point-marker))
634 (setq simple-address-list
635 (concat simple-address-list " "
636 (mail-strip-quoted-names (buffer-substring this-line this-line-end))))
637 )
638 (erase-buffer)
639 (insert-string " ")
640 (insert-string simple-address-list)
641 (insert-string "\n")
642 (subst-char-in-region (point-min) (point-max) 10 ? t);; newline --> blank
643 (subst-char-in-region (point-min) (point-max) ?, ? t);; comma --> blank
644 (subst-char-in-region (point-min) (point-max) 9 ? t);; tab --> blank
645
646 (goto-char (point-min))
647 ;; tidyness in case hook is not robust when it looks at this
648 (while (re-search-forward "[ \t]+" header-end t) (replace-match " "))
649
650 (goto-char (point-min))
651 (let (recipient-address-list)
652 (while (re-search-forward " \\([^ ]+\\) " (point-max) t)
653 (backward-char 1)
654 (setq recipient-address-list (cons (buffer-substring (match-beginning 1) (match-end 1))
655 recipient-address-list))
656 )
657 (setq smtpmail-recipient-address-list recipient-address-list))
658
659 )
660 )
661 )
662 )
663
664
665 (defun smtpmail-do-bcc (header-end)
666 "Delete [Resent-]BCC: and their continuation lines from the header area.
667 There may be multiple BCC: lines, and each may have arbitrarily
668 many continuation lines."
669 (let ((case-fold-search t))
670 (save-excursion (goto-char (point-min))
671 ;; iterate over all BCC: lines
672 (while (re-search-forward "^\(RESENT-\)?BCC:" header-end t)
673 (delete-region (match-beginning 0) (progn (forward-line 1) (point)))
674 ;; get rid of any continuation lines
675 (while (and (looking-at "^[ \t].*\n") (< (point) header-end))
676 (replace-match ""))
677 )
678 ) ;; save-excursion
679 ) ;; let
680 )
681
682
683
684 (provide 'smtpmail)
685
686 ;;; smtpmail.el ends here