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