annotate lisp/mail/smtpmail.el @ 17094:c237252970e5

(make-coding-system): For ISO-2022 type conding systems, new flags INIT-BOL DESIGNATION-BOL are added. (make-coding-system): Set charset (symbol) instead of charset-id (integer) in FLAGS of ISO-2022 type coding systems. Initialize a global variable use-default-ascent. (define-coding-system-alias): Coding style changed.
author Kenichi Handa <handa@m17n.org>
date Wed, 26 Feb 1997 13:01:42 +0000
parents 3c4a708a2631
children 2a9fdbfcb993
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;; Simple SMTP protocol (RFC 821) for sending mail
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
15451
89c1e7fe879a (smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents: 15372
diff changeset
3 ;; Copyright (C) 1995, 1996 Free Software Foundation, Inc.
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Tomoji Kagatani <kagatani@rbc.ncl.omron.co.jp>
15452
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
6 ;; Maintainer: Brian D. Carlstrom <bdc@ai.mit.edu>
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: mail
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; Send Mail to smtp host from smtpmail temp buffer.
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; Please add these lines in your .emacs(_emacs).
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;;
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;;(setq send-mail-function 'smtpmail-send-it)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;;(setq smtpmail-default-smtp-server "YOUR SMTP HOST")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;(setq smtpmail-smtp-service "smtp")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;;(setq smtpmail-local-domain "YOUR DOMAIN NAME")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;;(setq smtpmail-debug-info t)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;;(load-library "smtpmail")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;(setq smtpmail-code-conv-from nil)
15452
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
39 ;;(setq user-full-name "YOUR NAME HERE")
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;;; Code:
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (require 'sendmail)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;;;
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (defvar smtpmail-default-smtp-server nil
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 "*Specify default SMTP server.")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
15451
89c1e7fe879a (smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents: 15372
diff changeset
49 (defvar smtpmail-smtp-server
89c1e7fe879a (smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents: 15372
diff changeset
50 (or (getenv "SMTPSERVER") smtpmail-default-smtp-server)
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 "*The name of the host running SMTP server.")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
15451
89c1e7fe879a (smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents: 15372
diff changeset
53 (defvar smtpmail-smtp-service 25
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 "*SMTP service port number. smtp or 25 .")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (defvar smtpmail-local-domain nil
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 "*Local domain name without a host name.
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 If the function (system-name) returns the full internet address,
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 don't define this value.")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (defvar smtpmail-debug-info nil
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 "*smtpmail debug info printout. messages and process buffer.")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (defvar smtpmail-code-conv-from nil ;; *junet*
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 "*smtpmail code convert from this code to *internal*..for tiny-mime..")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;;;
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;;;
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;;;
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (defun smtpmail-send-it ()
15451
89c1e7fe879a (smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents: 15372
diff changeset
72 (require 'mail-utils)
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (let ((errbuf (if mail-interactive
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (generate-new-buffer " smtpmail errors")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 0))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (tembuf (generate-new-buffer " smtpmail temp"))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (case-fold-search nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 resend-to-addresses
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 delimline
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (mailbuf (current-buffer)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (unwind-protect
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (save-excursion
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (set-buffer tembuf)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (erase-buffer)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (insert-buffer-substring mailbuf)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (goto-char (point-max))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;; require one newline at the end.
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (or (= (preceding-char) ?\n)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (insert ?\n))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ;; Change header-delimiter to be what sendmail expects.
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (goto-char (point-min))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (re-search-forward
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (concat "^" (regexp-quote mail-header-separator) "\n"))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (replace-match "\n")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (backward-char 1)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (setq delimline (point-marker))
15451
89c1e7fe879a (smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents: 15372
diff changeset
97 ;; (sendmail-synch-aliases)
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (if mail-aliases
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (expand-mail-aliases (point-min) delimline))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (goto-char (point-min))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 ;; ignore any blank lines in the header
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (while (and (re-search-forward "\n\n\n*" delimline t)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 (< (point) delimline))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (replace-match "\n"))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (let ((case-fold-search t))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (goto-char (point-min))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (goto-char (point-min))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (while (re-search-forward "^Resent-to:" delimline t)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (setq resend-to-addresses
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (save-restriction
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (narrow-to-region (point)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (save-excursion
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (end-of-line)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (point)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (append (mail-parse-comma-list)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 resend-to-addresses))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;;; Apparently this causes a duplicate Sender.
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;;; ;; If the From is different than current user, insert Sender.
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ;;; (goto-char (point-min))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;;; (and (re-search-forward "^From:" delimline t)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;;; (progn
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;;; (require 'mail-utils)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;;; (not (string-equal
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;;; (mail-strip-quoted-names
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;;; (save-restriction
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ;;; (narrow-to-region (point-min) delimline)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;;; (mail-fetch-field "From")))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;;; (user-login-name))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;;; (progn
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;;; (forward-line 1)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 ;;; (insert "Sender: " (user-login-name) "\n")))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;; Don't send out a blank subject line
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (goto-char (point-min))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (if (re-search-forward "^Subject:[ \t]*\n" delimline t)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (replace-match ""))
15452
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
136 ;; Put the "From:" field in unless for some odd reason
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
137 ;; they put one in themselves.
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
138 (goto-char (point-min))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
139 (if (not (re-search-forward "^From:" delimline t))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
140 (let* ((login user-mail-address)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
141 (fullname (user-full-name)))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
142 (cond ((eq mail-from-style 'angles)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
143 (insert "From: " fullname)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
144 (let ((fullname-start (+ (point-min) 6))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
145 (fullname-end (point-marker)))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
146 (goto-char fullname-start)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
147 ;; Look for a character that cannot appear unquoted
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
148 ;; according to RFC 822.
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
149 (if (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]"
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
150 fullname-end 1)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
151 (progn
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
152 ;; Quote fullname, escaping specials.
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
153 (goto-char fullname-start)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
154 (insert "\"")
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
155 (while (re-search-forward "[\"\\]"
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
156 fullname-end 1)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
157 (replace-match "\\\\\\&" t))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
158 (insert "\""))))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
159 (insert " <" login ">\n"))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
160 ((eq mail-from-style 'parens)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
161 (insert "From: " login " (")
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
162 (let ((fullname-start (point)))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
163 (insert fullname)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
164 (let ((fullname-end (point-marker)))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
165 (goto-char fullname-start)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
166 ;; RFC 822 says \ and nonmatching parentheses
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
167 ;; must be escaped in comments.
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
168 ;; Escape every instance of ()\ ...
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
169 (while (re-search-forward "[()\\]" fullname-end 1)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
170 (replace-match "\\\\\\&" t))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
171 ;; ... then undo escaping of matching parentheses,
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
172 ;; including matching nested parentheses.
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
173 (goto-char fullname-start)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
174 (while (re-search-forward
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
175 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)"
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
176 fullname-end 1)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
177 (replace-match "\\1(\\3)" t)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
178 (goto-char fullname-start))))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
179 (insert ")\n"))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
180 ((null mail-from-style)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
181 (insert "From: " login "\n")))))
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 ;; Insert an extra newline if we need it to work around
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ;; Sun's bug that swallows newlines.
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (goto-char (1+ delimline))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (if (eval mail-mailer-swallows-blank-line)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (newline))
15452
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
187 ;; Find and handle any FCC fields.
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
188 (goto-char (point-min))
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
189 (if (re-search-forward "^FCC:" delimline t)
6f41e17b3452 (smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents: 15451
diff changeset
190 (mail-do-fcc delimline))
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (if mail-interactive
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (save-excursion
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (set-buffer errbuf)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (erase-buffer))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 ;;
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 ;;
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 ;;
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (setq smtpmail-address-buffer (generate-new-buffer "*smtp-mail*"))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (setq smtpmail-recipient-address-list
15595
0d4a7f47f31d (smtpmail-send-it): Ignore `To:' if there is a `Resent-to':.
Miles Bader <miles@gnu.org>
parents: 15454
diff changeset
200 (or resend-to-addresses
0d4a7f47f31d (smtpmail-send-it): Ignore `To:' if there is a `Resent-to':.
Miles Bader <miles@gnu.org>
parents: 15454
diff changeset
201 (smtpmail-deduce-address-list tembuf (point-min) delimline)))
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (kill-buffer smtpmail-address-buffer)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (smtpmail-do-bcc delimline)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (if (not (null smtpmail-recipient-address-list))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (if (not (smtpmail-via-smtp smtpmail-recipient-address-list tembuf))
15346
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
208 (error "Sending failed; SMTP protocol error"))
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
209 (error "Sending failed; no recipients"))
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (kill-buffer tembuf)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (if (bufferp errbuf)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (kill-buffer errbuf)))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 ;(defun smtpmail-via-smtp (host,port,sender,destination,smtpmail-text-buffer)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (defun smtpmail-fqdn ()
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (if smtpmail-local-domain
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (concat (system-name) "." smtpmail-local-domain)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (system-name)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (defun smtpmail-via-smtp (recipient smtpmail-text-buffer)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (let ((process nil)
15346
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
225 (host smtpmail-smtp-server)
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
226 (port smtpmail-smtp-service)
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 response-code
15346
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
228 greeting
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
229 process-buffer)
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (unwind-protect
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (catch 'done
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 ;; get or create the trace buffer
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (setq process-buffer
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (get-buffer-create (format "*trace of SMTP session to %s*" host)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 ;; clear the trace buffer of old output
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (save-excursion
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (set-buffer process-buffer)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (erase-buffer))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 ;; open the connection to the server
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (setq process (open-network-stream "SMTP" process-buffer host port))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (and (null process) (throw 'done nil))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 ;; set the send-filter
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (set-process-filter process 'smtpmail-process-filter)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (save-excursion
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (set-buffer process-buffer)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (make-local-variable 'smtpmail-read-point)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (setq smtpmail-read-point (point-min))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (if (or (null (car (setq greeting (smtpmail-read-response process))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (not (integerp (car greeting)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (>= (car greeting) 400))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (throw 'done nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 ;; HELO
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (smtpmail-send-command process (format "HELO %s" (smtpmail-fqdn)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (if (or (null (car (setq response-code (smtpmail-read-response process))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (not (integerp (car response-code)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (>= (car response-code) 400))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (throw 'done nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 ;; MAIL FROM: <sender>
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 ; (smtpmail-send-command process (format "MAIL FROM:%s@%s" (user-login-name) (smtpmail-fqdn)))
15453
ad4f0ac5e7ef (smtpmail-via-smtp): Bracket names in FROM and RCPT TO commands.
Richard M. Stallman <rms@gnu.org>
parents: 15452
diff changeset
271 (smtpmail-send-command process (format "MAIL FROM: <%s>" user-mail-address))
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (if (or (null (car (setq response-code (smtpmail-read-response process))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (not (integerp (car response-code)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (>= (car response-code) 400))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (throw 'done nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 ;; RCPT TO: <recipient>
15346
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
280 (let ((n 0))
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
281 (while (not (null (nth n recipient)))
15453
ad4f0ac5e7ef (smtpmail-via-smtp): Bracket names in FROM and RCPT TO commands.
Richard M. Stallman <rms@gnu.org>
parents: 15452
diff changeset
282 (smtpmail-send-command process (format "RCPT TO: <%s>" (nth n recipient)))
15346
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
283 (setq n (1+ n))
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284
15346
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
285 (if (or (null (car (setq response-code (smtpmail-read-response process))))
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
286 (not (integerp (car response-code)))
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
287 (>= (car response-code) 400))
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
288 (throw 'done nil)
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
289 )
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
290 ))
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 ;; DATA
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (smtpmail-send-command process "DATA")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (if (or (null (car (setq response-code (smtpmail-read-response process))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (not (integerp (car response-code)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (>= (car response-code) 400))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (throw 'done nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 ;; Mail contents
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (smtpmail-send-data process smtpmail-text-buffer)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 ;;DATA end "."
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (smtpmail-send-command process ".")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (if (or (null (car (setq response-code (smtpmail-read-response process))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (not (integerp (car response-code)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (>= (car response-code) 400))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 (throw 'done nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 ;;QUIT
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 ; (smtpmail-send-command process "QUIT")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 ; (and (null (car (smtpmail-read-response process)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 ; (throw 'done nil))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 t ))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (if process
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (save-excursion
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (set-buffer (process-buffer process))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (smtpmail-send-command process "QUIT")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (smtpmail-read-response process)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 ; (if (or (null (car (setq response-code (smtpmail-read-response process))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 ; (not (integerp (car response-code)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 ; (>= (car response-code) 400))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 ; (throw 'done nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 ; )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (delete-process process))))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (defun smtpmail-process-filter (process output)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (save-excursion
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (set-buffer (process-buffer process))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (goto-char (point-max))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (insert output)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (defun smtpmail-read-response (process)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (let ((case-fold-search nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (response-string nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (response-continue t)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (return-value '(nil ""))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 match-end)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 ; (setq response-string nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 ; (setq response-continue t)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 ; (setq return-value '(nil ""))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (while response-continue
15454
85313b347ed9 (smtpmail-read-response): Goto smtpmail-read-point
Richard M. Stallman <rms@gnu.org>
parents: 15453
diff changeset
350 (goto-char smtpmail-read-point)
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (while (not (search-forward "\r\n" nil t))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (accept-process-output process)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 (goto-char smtpmail-read-point))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 (setq match-end (point))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 (if (null response-string)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 (setq response-string
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 (buffer-substring smtpmail-read-point (- match-end 2))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (goto-char smtpmail-read-point)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 (if (looking-at "[0-9]+ ")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 (progn (setq response-continue nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 ; (setq return-value response-string)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 (if smtpmail-debug-info
16907
3c4a708a2631 (smtpmail-read-response): Don't get confused by %'s in response-string.
Richard M. Stallman <rms@gnu.org>
parents: 15676
diff changeset
366 (message "%s" response-string))
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (setq smtpmail-read-point match-end)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 (setq return-value
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 (cons (string-to-int
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (buffer-substring (match-beginning 0) (match-end 0)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 response-string)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (if (looking-at "[0-9]+-")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (progn (setq smtpmail-read-point match-end)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (setq response-continue t))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (progn
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 (setq smtpmail-read-point match-end)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (setq response-continue nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (setq return-value
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (cons nil response-string))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 )))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (setq smtpmail-read-point match-end)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 return-value))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 (defun smtpmail-send-command (process command)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (goto-char (point-max))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 (if (= (aref command 0) ?P)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (insert "PASS <omitted>\r\n")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (insert command "\r\n"))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 (setq smtpmail-read-point (point))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 (process-send-string process command)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (process-send-string process "\r\n"))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 (defun smtpmail-send-data-1 (process data)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (goto-char (point-max))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (if (not (null smtpmail-code-conv-from))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (setq data (code-convert-string data smtpmail-code-conv-from *internal*)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (if smtpmail-debug-info
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (insert data "\r\n"))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (setq smtpmail-read-point (point))
15676
46d74bda4351 (smtpmail-send-data-1): Escape "." at the start of
Karl Heuer <kwzh@gnu.org>
parents: 15648
diff changeset
407 ;; Escape "." at start of a line
46d74bda4351 (smtpmail-send-data-1): Escape "." at the start of
Karl Heuer <kwzh@gnu.org>
parents: 15648
diff changeset
408 (if (eq (string-to-char data) ?.)
46d74bda4351 (smtpmail-send-data-1): Escape "." at the start of
Karl Heuer <kwzh@gnu.org>
parents: 15648
diff changeset
409 (process-send-string process "."))
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (process-send-string process data)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (process-send-string process "\r\n")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (defun smtpmail-send-data (process buffer)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (let
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 ((data-continue t)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (sending-data nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 this-line
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 this-line-end)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (save-excursion
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (set-buffer buffer)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (goto-char (point-min)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (while data-continue
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (save-excursion
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (set-buffer buffer)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (beginning-of-line)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (setq this-line (point))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (end-of-line)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (setq this-line-end (point))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 (setq sending-data nil)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (setq sending-data (buffer-substring this-line this-line-end))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (if (/= (forward-line 1) 0)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (setq data-continue nil)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (smtpmail-send-data-1 process sending-data)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (defun smtpmail-deduce-address-list (smtpmail-text-buffer header-start header-end)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 "Get address list suitable for smtp RCPT TO: <address>."
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (require 'mail-utils) ;; pick up mail-strip-quoted-names
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (let
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 ((case-fold-search t)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (simple-address-list "")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 this-line
15648
2feeabc94834 (smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents: 15595
diff changeset
450 this-line-end
2feeabc94834 (smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents: 15595
diff changeset
451 addr-regexp)
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 (unwind-protect
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 (save-excursion
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 ;;
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (set-buffer smtpmail-address-buffer) (erase-buffer)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (insert-buffer-substring smtpmail-text-buffer header-start header-end)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 (goto-char (point-min))
15648
2feeabc94834 (smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents: 15595
diff changeset
459 ;; RESENT-* fields should stop processing of regular fields.
2feeabc94834 (smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents: 15595
diff changeset
460 (save-excursion
2feeabc94834 (smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents: 15595
diff changeset
461 (if (re-search-forward "^RESENT-TO:" header-end t)
2feeabc94834 (smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents: 15595
diff changeset
462 (setq addr-regexp "^\\(RESENT-TO:\\|RESENT-CC:\\|RESENT-BCC:\\)")
2feeabc94834 (smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents: 15595
diff changeset
463 (setq addr-regexp "^\\(TO:\\|CC:\\|BCC:\\)")))
2feeabc94834 (smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents: 15595
diff changeset
464
2feeabc94834 (smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents: 15595
diff changeset
465 (while (re-search-forward addr-regexp header-end t)
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 (replace-match "")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (setq this-line (match-beginning 0))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 (forward-line 1)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 ;; get any continuation lines
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (while (and (looking-at "^[ \t]+") (< (point) header-end))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 (forward-line 1))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 (setq this-line-end (point-marker))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 (setq simple-address-list
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 (concat simple-address-list " "
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (mail-strip-quoted-names (buffer-substring this-line this-line-end))))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (erase-buffer)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (insert-string " ")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (insert-string simple-address-list)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (insert-string "\n")
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (subst-char-in-region (point-min) (point-max) 10 ? t);; newline --> blank
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 (subst-char-in-region (point-min) (point-max) ?, ? t);; comma --> blank
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (subst-char-in-region (point-min) (point-max) 9 ? t);; tab --> blank
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (goto-char (point-min))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 ;; tidyness in case hook is not robust when it looks at this
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (while (re-search-forward "[ \t]+" header-end t) (replace-match " "))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (goto-char (point-min))
15346
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
490 (let (recipient-address-list)
15451
89c1e7fe879a (smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents: 15372
diff changeset
491 (while (re-search-forward " \\([^ ]+\\) " (point-max) t)
15346
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
492 (backward-char 1)
15451
89c1e7fe879a (smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents: 15372
diff changeset
493 (setq recipient-address-list (cons (buffer-substring (match-beginning 1) (match-end 1))
89c1e7fe879a (smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents: 15372
diff changeset
494 recipient-address-list))
15346
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
495 )
4cd6ff2384dc (smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents: 15345
diff changeset
496 (setq smtpmail-recipient-address-list recipient-address-list))
15345
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (defun smtpmail-do-bcc (header-end)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 "Delete BCC: and their continuation lines from the header area.
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 There may be multiple BCC: lines, and each may have arbitrarily
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 many continuation lines."
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (let ((case-fold-search t))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (save-excursion (goto-char (point-min))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 ;; iterate over all BCC: lines
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (while (re-search-forward "^BCC:" header-end t)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (delete-region (match-beginning 0) (progn (forward-line 1) (point)))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 ;; get rid of any continuation lines
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (while (and (looking-at "^[ \t].*\n") (< (point) header-end))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 (replace-match ""))
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 ) ;; save-excursion
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 ) ;; let
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 )
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 (provide 'smtpmail)
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524
4eef6c1687f8 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 ;; smtpmail.el ends here