annotate lisp/mail/smtpmail.el @ 24319:a26d4126c64b

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