Mercurial > emacs
annotate lisp/mail/smtpmail.el @ 42914:4df576b320fb
Minor explanation.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 23 Jan 2002 00:00:23 +0000 |
parents | 8ef1ae58dc29 |
children | c18dd95f6962 |
rev | line source |
---|---|
17517 | 1 ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail |
15345 | 2 |
37598
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
3 ;; Copyright (C) 1995, 1996, 2001 Free Software Foundation, Inc. |
15345 | 4 |
5 ;; Author: Tomoji Kagatani <kagatani@rbc.ncl.omron.co.jp> | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
6 ;; Maintainer: Simon Josefsson <simon@josefsson.org> |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
7 ;; w32 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
|
8 ;; ESMTP support: Simon Leinen <simon@switch.ch> |
37800
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
9 ;; Hacked by Mike Taylor, 11th October 1999 to add support for |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
10 ;; automatically appending a domain to RCPT TO: addresses. |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
11 ;; AUTH=LOGIN support: Stephen Cranefield <scranefield@infoscience.otago.ac.nz> |
15345 | 12 ;; Keywords: mail |
13 | |
14 ;; This file is part of GNU Emacs. | |
15 | |
16 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
17 ;; it under the terms of the GNU General Public License as published by | |
18 ;; the Free Software Foundation; either version 2, or (at your option) | |
19 ;; any later version. | |
20 | |
21 ;; GNU Emacs is distributed in the hope that it will be useful, | |
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 ;; GNU General Public License for more details. | |
25 | |
26 ;; You should have received a copy of the GNU General Public License | |
27 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
28 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
29 ;; Boston, MA 02111-1307, USA. | |
30 | |
31 ;;; Commentary: | |
32 | |
33 ;; Send Mail to smtp host from smtpmail temp buffer. | |
34 | |
23142
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
35 ;; Please add these lines in your .emacs(_emacs) or use customize. |
15345 | 36 ;; |
23142
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
37 ;;(setq send-mail-function 'smtpmail-send-it) ; if you use `mail' |
38725 | 38 ;;(setq message-send-mail-function 'smtpmail-send-it) ; if you are using Gnus. |
15345 | 39 ;;(setq smtpmail-default-smtp-server "YOUR SMTP HOST") |
40 ;;(setq smtpmail-local-domain "YOUR DOMAIN NAME") | |
26028
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
41 ;;(setq smtpmail-sendto-domain "YOUR DOMAIN NAME") |
23142
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
42 ;;(setq smtpmail-debug-info t) ; only to debug problems |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
43 ;;(setq smtpmail-auth-credentials |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
44 ;; '(("YOUR SMTP HOST" 25 "username" "password"))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
45 ;;(setq smtpmail-starttls-credentials |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
46 ;; '(("YOUR SMTP HOST" 25 "~/.my_smtp_tls.key" "~/.my_smtp_tls.cert"))) |
15345 | 47 |
18094 | 48 ;; To queue mail, set smtpmail-queue-mail to t and use |
49 ;; smtpmail-send-queued-mail to send. | |
50 | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
51 ;; Modified by Stephen Cranefield <scranefield@infoscience.otago.ac.nz>, |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
52 ;; 22/6/99, to support SMTP Authentication by the AUTH=LOGIN mechanism. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
53 ;; See http://help.netscape.com/products/server/messaging/3x/info/smtpauth.html |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
54 ;; Rewritten by Simon Josefsson to use same credential variable as AUTH |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
55 ;; support below. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
56 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
57 ;; Modified by Simon Josefsson <jas@pdc.kth.se>, 22/2/99, to support SMTP |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
58 ;; Authentication by the AUTH mechanism. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
59 ;; See http://www.ietf.org/rfc/rfc2554.txt |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
60 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
61 ;; Modified by Simon Josefsson <simon@josefsson.org>, 2000-10-07, to support |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
62 ;; STARTTLS. Requires external program |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
63 ;; ftp://ftp.opaopa.org/pub/elisp/starttls-*.tar.gz. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
64 ;; See http://www.ietf.org/rfc/rfc2246.txt, http://www.ietf.org/rfc/rfc2487.txt |
18094 | 65 |
15345 | 66 ;;; Code: |
67 | |
68 (require 'sendmail) | |
18094 | 69 (require 'time-stamp) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
70 (autoload 'starttls-open-stream "starttls") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
71 (autoload 'starttls-negotiate "starttls") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
72 (autoload 'mail-strip-quoted-names "mail-utils") |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
73 (autoload 'message-make-date "message") |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
74 (autoload 'message-make-message-id "message") |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
75 (autoload 'rfc2104-hash "rfc2104") |
15345 | 76 |
77 ;;; | |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
78 (defgroup smtpmail nil |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
79 "SMTP protocol for sending mail." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
80 :group 'mail) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
81 |
15345 | 82 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
83 (defcustom smtpmail-default-smtp-server nil |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
84 "*Specify default SMTP server." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
85 :type '(choice (const nil) string) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
86 :group 'smtpmail) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
87 |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
88 (defcustom smtpmail-smtp-server |
15451
89c1e7fe879a
(smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents:
15372
diff
changeset
|
89 (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
|
90 "*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
|
91 :type '(choice (const nil) string) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
92 :group 'smtpmail) |
15345 | 93 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
94 (defcustom smtpmail-smtp-service 25 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
95 "*SMTP service port number. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
96 The default value would be \"smtp\" or 25 ." |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
97 :type '(choice (integer :tag "Port") (string :tag "Service")) |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
98 :group 'smtpmail) |
15345 | 99 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
100 (defcustom smtpmail-local-domain nil |
15345 | 101 "*Local domain name without a host name. |
102 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
|
103 don't define this value." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
104 :type '(choice (const nil) string) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
105 :group 'smtpmail) |
15345 | 106 |
26028
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
107 (defcustom smtpmail-sendto-domain nil |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
108 "*Local domain name without a host name. |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
109 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
|
110 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
|
111 \(Some configurations of sendmail require this.) |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
112 |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
113 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
|
114 Sending failed; SMTP protocol error |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
115 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
|
116 buffer includes an exchange like: |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
117 RCPT TO: <someone> |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
118 501 <someone>: recipient address must contain a domain |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
119 " |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
120 :type '(choice (const nil) string) |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
121 :group 'smtpmail) |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
122 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
123 (defcustom smtpmail-debug-info nil |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
124 "Whether to print info in buffer *trace of SMTP session to <somewhere>*. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
125 See also `smtpmail-debug-verb' which determines if the SMTP protocol should |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
126 be verbose as well." |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
127 :type 'boolean |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
128 :group 'smtpmail) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
129 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
130 (defcustom smtpmail-debug-verb nil |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
131 "Whether this library sends the SMTP VERB command or not. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
132 The commands enables verbose information from the SMTP server." |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
133 :type 'boolean |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
134 :group 'smtpmail) |
15345 | 135 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
136 (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
|
137 "*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
|
138 :type 'boolean |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
139 :group 'smtpmail) |
15345 | 140 |
18094 | 141 (defcustom smtpmail-queue-mail nil |
142 "*Specify if mail is queued (if t) or sent immediately (if nil). | |
143 If queued, it is stored in the directory `smtpmail-queue-dir' | |
144 and sent with `smtpmail-send-queued-mail'." | |
145 :type 'boolean | |
146 :group 'smtpmail) | |
147 | |
148 (defcustom smtpmail-queue-dir "~/Mail/queued-mail/" | |
149 "*Directory where `smtpmail.el' stores queued mail." | |
150 :type 'directory | |
151 :group 'smtpmail) | |
152 | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
153 (defcustom smtpmail-auth-credentials '(("" 25 "" nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
154 "Specify username and password for servers. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
155 It is a list of four-element lists that contain, in order, |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
156 `servername' (a string), `port' (an integer), `user' (a string) and |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
157 `password' (a string, or nil to query the user when needed). |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
158 If you need to enter a `realm' too, add it to the user string, so that |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
159 it looks like `user@realm'." |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
160 :type '(repeat (list (string :tag "Server") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
161 (integer :tag "Port") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
162 (string :tag "Username") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
163 (choice (const :tag "Query when needed" nil) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
164 (string :tag "Password")))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
165 :version "21.1" |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
166 :group 'smtpmail) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
167 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
168 (defcustom smtpmail-starttls-credentials '(("" 25 "" "")) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
169 "Specify STARTTLS keys and certificates for servers. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
170 This is a list of four-element list with `servername' (a string), |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
171 `port' (an integer), `key' (a filename) and `certificate' (a filename)." |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
172 :type '(repeat (list (string :tag "Server") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
173 (integer :tag "Port") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
174 (file :tag "Key") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
175 (file :tag "Certificate"))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
176 :version "21.1" |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
177 :group 'smtpmail) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
178 |
37598
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
179 (defcustom smtpmail-warn-about-unknown-extensions nil |
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
180 "*If set, print warnings about unknown SMTP extensions. |
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
181 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
|
182 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
|
183 :type 'boolean |
37600
20c37aac51cd
(smtpmail-warn-about-unknown-extensions): Add :version.
Gerd Moellmann <gerd@gnu.org>
parents:
37598
diff
changeset
|
184 :version "21.1" |
37598
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
185 :group 'smtpmail) |
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
186 |
18094 | 187 (defvar smtpmail-queue-index-file "index" |
188 "File name of queued mail index, | |
189 This is relative to `smtpmail-queue-dir'.") | |
190 | |
23444
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
191 (defvar smtpmail-address-buffer) |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
192 (defvar smtpmail-recipient-address-list) |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
193 |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
194 ;; Buffer-local variable. |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
195 (defvar smtpmail-read-point) |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
196 |
18094 | 197 (defvar smtpmail-queue-index (concat smtpmail-queue-dir |
198 smtpmail-queue-index-file)) | |
199 | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
200 (defconst smtpmail-auth-supported '(cram-md5 login) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
201 "List of supported SMTP AUTH mechanisms.") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
202 |
15345 | 203 ;;; |
204 ;;; | |
205 ;;; | |
206 | |
23142
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
207 ;;;###autoload |
15345 | 208 (defun smtpmail-send-it () |
209 (let ((errbuf (if mail-interactive | |
210 (generate-new-buffer " smtpmail errors") | |
211 0)) | |
212 (tembuf (generate-new-buffer " smtpmail temp")) | |
213 (case-fold-search nil) | |
214 delimline | |
24773 | 215 (mailbuf (current-buffer)) |
216 (smtpmail-code-conv-from | |
217 (if enable-multibyte-characters | |
218 (let ((sendmail-coding-system smtpmail-code-conv-from)) | |
219 (select-message-coding-system))))) | |
15345 | 220 (unwind-protect |
221 (save-excursion | |
222 (set-buffer tembuf) | |
223 (erase-buffer) | |
224 (insert-buffer-substring mailbuf) | |
225 (goto-char (point-max)) | |
226 ;; require one newline at the end. | |
227 (or (= (preceding-char) ?\n) | |
228 (insert ?\n)) | |
229 ;; 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
|
230 (mail-sendmail-undelimit-header) |
15345 | 231 (setq delimline (point-marker)) |
15451
89c1e7fe879a
(smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents:
15372
diff
changeset
|
232 ;; (sendmail-synch-aliases) |
15345 | 233 (if mail-aliases |
234 (expand-mail-aliases (point-min) delimline)) | |
235 (goto-char (point-min)) | |
236 ;; ignore any blank lines in the header | |
237 (while (and (re-search-forward "\n\n\n*" delimline t) | |
238 (< (point) delimline)) | |
239 (replace-match "\n")) | |
240 (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
|
241 ;; 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
|
242 ;; 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
|
243 ;; is done correctly in smtpmail-deduce-address-list. |
15345 | 244 ;; Don't send out a blank subject line |
245 (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
|
246 (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
|
247 (replace-match "") |
dfb671ba22f8
(smtpmail-send-it): Deleted all code related to Resent-To: processing.
Richard M. Stallman <rms@gnu.org>
parents:
20058
diff
changeset
|
248 ;; 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
|
249 (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
|
250 (= (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
|
251 (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
|
252 ;; 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
|
253 ;; 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
|
254 (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
|
255 (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
|
256 (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
|
257 (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
|
258 (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
|
259 (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
|
260 (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
|
261 (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
|
262 (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
|
263 ;; 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
|
264 ;; 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
|
265 (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
|
266 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
|
267 (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
|
268 ;; 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
|
269 (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
|
270 (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
|
271 (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
|
272 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
|
273 (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
|
274 (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
|
275 (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
|
276 ((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
|
277 (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
|
278 (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
|
279 (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
|
280 (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
|
281 (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
|
282 ;; 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
|
283 ;; 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
|
284 ;; 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
|
285 (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
|
286 (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
|
287 ;; ... 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
|
288 ;; 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
|
289 (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
|
290 (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
|
291 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)" |
6f41e17b3452
(smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents:
15451
diff
changeset
|
292 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
|
293 (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
|
294 (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
|
295 (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
|
296 ((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
|
297 (insert "From: " login "\n"))))) |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
298 ;; Insert a `Message-Id:' field if there isn't one yet. |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
299 (goto-char (point-min)) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
300 (unless (re-search-forward "^Message-Id:" delimline t) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
301 (insert "Message-Id: " (message-make-message-id) "\n")) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
302 ;; Insert a `Date:' field if there isn't one yet. |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
303 (goto-char (point-min)) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
304 (unless (re-search-forward "^Date:" delimline t) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
305 (insert "Date: " (message-make-date) "\n")) |
15345 | 306 ;; Insert an extra newline if we need it to work around |
307 ;; Sun's bug that swallows newlines. | |
308 (goto-char (1+ delimline)) | |
309 (if (eval mail-mailer-swallows-blank-line) | |
310 (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
|
311 ;; 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
|
312 (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
|
313 (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
|
314 (mail-do-fcc delimline)) |
15345 | 315 (if mail-interactive |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
316 (with-current-buffer errbuf |
15345 | 317 (erase-buffer)))) |
318 ;; | |
319 ;; | |
320 ;; | |
321 (setq smtpmail-address-buffer (generate-new-buffer "*smtp-mail*")) | |
322 (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
|
323 (smtpmail-deduce-address-list tembuf (point-min) delimline)) |
15345 | 324 (kill-buffer smtpmail-address-buffer) |
18094 | 325 |
15345 | 326 (smtpmail-do-bcc delimline) |
18094 | 327 ; Send or queue |
328 (if (not smtpmail-queue-mail) | |
329 (if (not (null smtpmail-recipient-address-list)) | |
330 (if (not (smtpmail-via-smtp | |
331 smtpmail-recipient-address-list tembuf)) | |
332 (error "Sending failed; SMTP protocol error")) | |
333 (error "Sending failed; no recipients")) | |
334 (let* ((file-data (concat | |
335 smtpmail-queue-dir | |
20058
7077ba8a265b
(smtpmail-send-it): Don't use time-stamp-strftime.
Karl Heuer <kwzh@gnu.org>
parents:
18094
diff
changeset
|
336 (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
|
337 "_" (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
|
338 (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
|
339 (file-elisp (concat file-data ".el")) |
18094 | 340 (buffer-data (create-file-buffer file-data)) |
341 (buffer-elisp (create-file-buffer file-elisp)) | |
342 (buffer-scratch "*queue-mail*")) | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
343 (with-current-buffer buffer-data |
18094 | 344 (erase-buffer) |
345 (insert-buffer tembuf) | |
346 (write-file file-data) | |
347 (set-buffer buffer-elisp) | |
348 (erase-buffer) | |
349 (insert (concat | |
350 "(setq smtpmail-recipient-address-list '" | |
351 (prin1-to-string smtpmail-recipient-address-list) | |
352 ")\n")) | |
353 (write-file file-elisp) | |
354 (set-buffer (generate-new-buffer buffer-scratch)) | |
355 (insert (concat file-data "\n")) | |
356 (append-to-file (point-min) | |
357 (point-max) | |
358 smtpmail-queue-index) | |
359 ) | |
360 (kill-buffer buffer-scratch) | |
361 (kill-buffer buffer-data) | |
362 (kill-buffer buffer-elisp)))) | |
15345 | 363 (kill-buffer tembuf) |
364 (if (bufferp errbuf) | |
365 (kill-buffer errbuf))))) | |
366 | |
18094 | 367 (defun smtpmail-send-queued-mail () |
368 "Send mail that was queued as a result of setting `smtpmail-queue-mail'." | |
369 (interactive) | |
42225
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
370 (with-temp-buffer |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
371 ;;; Get index, get first mail, send it, update index, get second |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
372 ;;; mail, send it, etc... |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
373 (let ((file-msg "")) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
374 (insert-file-contents smtpmail-queue-index) |
18094 | 375 (beginning-of-buffer) |
376 (while (not (eobp)) | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
377 (setq file-msg (buffer-substring (point) (line-end-position))) |
18094 | 378 (load file-msg) |
41921
de4a90cd0a5f
(smtpmail-send-queued-mail): Insert the enqueued messages literally.
Eli Zaretskii <eliz@gnu.org>
parents:
41716
diff
changeset
|
379 ;; Insert the message literally: it is already encoded as per |
de4a90cd0a5f
(smtpmail-send-queued-mail): Insert the enqueued messages literally.
Eli Zaretskii <eliz@gnu.org>
parents:
41716
diff
changeset
|
380 ;; the MIME headers, and code conversions might guess the |
de4a90cd0a5f
(smtpmail-send-queued-mail): Insert the enqueued messages literally.
Eli Zaretskii <eliz@gnu.org>
parents:
41716
diff
changeset
|
381 ;; encoding wrongly. |
42225
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
382 (with-temp-buffer |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
383 (let ((coding-system-for-read 'no-conversion)) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
384 (insert-file-contents file-msg)) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
385 (if (not (null smtpmail-recipient-address-list)) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
386 (if (not (smtpmail-via-smtp smtpmail-recipient-address-list |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
387 (current-buffer))) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
388 (error "Sending failed; SMTP protocol error")) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
389 (error "Sending failed; no recipients"))) |
18094 | 390 (delete-file file-msg) |
391 (delete-file (concat file-msg ".el")) | |
42225
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
392 (kill-line 1)) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
393 (write-region (point-min) (point-max) smtpmail-queue-index)))) |
15345 | 394 |
395 ;(defun smtpmail-via-smtp (host,port,sender,destination,smtpmail-text-buffer) | |
396 | |
397 (defun smtpmail-fqdn () | |
398 (if smtpmail-local-domain | |
399 (concat (system-name) "." smtpmail-local-domain) | |
400 (system-name))) | |
401 | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
402 (defsubst smtpmail-cred-server (cred) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
403 (nth 0 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
404 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
405 (defsubst smtpmail-cred-port (cred) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
406 (nth 1 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
407 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
408 (defsubst smtpmail-cred-key (cred) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
409 (nth 2 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
410 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
411 (defsubst smtpmail-cred-user (cred) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
412 (nth 2 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
413 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
414 (defsubst smtpmail-cred-cert (cred) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
415 (nth 3 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
416 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
417 (defsubst smtpmail-cred-passwd (cred) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
418 (nth 3 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
419 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
420 (defun smtpmail-find-credentials (cred server port) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
421 (catch 'done |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
422 (let ((l cred) el) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
423 (while (setq el (pop l)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
424 (when (and (equal server (smtpmail-cred-server el)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
425 (equal port (smtpmail-cred-port el))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
426 (throw 'done el)))))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
427 |
37800
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
428 (defun smtpmail-maybe-append-domain (recipient) |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
429 (if (or (not smtpmail-sendto-domain) |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
430 (string-match "@" recipient)) |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
431 recipient |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
432 (concat recipient "@" smtpmail-sendto-domain))) |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
433 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
434 (defun smtpmail-intersection (list1 list2) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
435 (let ((result nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
436 (dolist (el2 list2) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
437 (when (memq el2 list1) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
438 (push el2 result))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
439 (nreverse result))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
440 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
441 (defun smtpmail-open-stream (process-buffer host port) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
442 (let ((cred (smtpmail-find-credentials |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
443 smtpmail-starttls-credentials host port))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
444 (if (null (and cred (condition-case () |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
445 (call-process "starttls") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
446 (error nil)))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
447 ;; The normal case. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
448 (open-network-stream "SMTP" process-buffer host port) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
449 (let* ((cred-key (smtpmail-cred-key cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
450 (cred-cert (smtpmail-cred-cert cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
451 (starttls-extra-args |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
452 (when (and (stringp cred-key) (stringp cred-cert) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
453 (file-regular-p |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
454 (setq cred-key (expand-file-name cred-key))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
455 (file-regular-p |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
456 (setq cred-cert (expand-file-name cred-cert)))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
457 (list "--key-file" cred-key "--cert-file" cred-cert)))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
458 (starttls-open-stream "SMTP" process-buffer host port))))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
459 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
460 (defun smtpmail-try-auth-methods (process supported-extensions host port) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
461 (let* ((mechs (cdr-safe (assoc 'auth supported-extensions))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
462 (mech (car (smtpmail-intersection smtpmail-auth-supported mechs))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
463 (cred (smtpmail-find-credentials smtpmail-auth-credentials host port)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
464 (passwd (when cred |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
465 (or (smtpmail-cred-passwd cred) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
466 (read-passwd |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
467 (format "SMTP password for %s:%s: " |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
468 (smtpmail-cred-server cred) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
469 (smtpmail-cred-port cred)))))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
470 ret) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
471 (when cred |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
472 (cond |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
473 ((eq mech 'cram-md5) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
474 (smtpmail-send-command process (format "AUTH %s" mech)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
475 (if (or (null (car (setq ret (smtpmail-read-response process)))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
476 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
477 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
478 (throw 'done nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
479 (when (eq (car ret) 334) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
480 (let* ((challenge (substring (cadr ret) 4)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
481 (decoded (base64-decode-string challenge)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
482 (hash (rfc2104-hash 'md5 64 16 passwd decoded)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
483 (response (concat (smtpmail-cred-user cred) " " hash)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
484 (encoded (base64-encode-string response))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
485 (smtpmail-send-command process (format "%s" encoded)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
486 (if (or (null (car (setq ret (smtpmail-read-response process)))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
487 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
488 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
489 (throw 'done nil))))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
490 ((eq mech 'login) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
491 (smtpmail-send-command process "AUTH LOGIN") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
492 (if (or (null (car (setq ret (smtpmail-read-response process)))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
493 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
494 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
495 (throw 'done nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
496 (smtpmail-send-command |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
497 process (base64-encode-string (smtpmail-cred-user cred))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
498 (if (or (null (car (setq ret (smtpmail-read-response process)))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
499 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
500 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
501 (throw 'done nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
502 (smtpmail-send-command process (base64-encode-string passwd)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
503 (if (or (null (car (setq ret (smtpmail-read-response process)))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
504 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
505 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
506 (throw 'done nil))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
507 (t |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
508 (error "Mechanism %s not implemented" mech))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
509 ;; Remember the password. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
510 (unless (smtpmail-cred-passwd cred) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
511 (setcar (cdr (cdr (cdr cred))) passwd))))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
512 |
15345 | 513 (defun smtpmail-via-smtp (recipient smtpmail-text-buffer) |
514 (let ((process nil) | |
23142
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
515 (host (or smtpmail-smtp-server |
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
516 (error "`smtpmail-smtp-server' not defined"))) |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
517 (port smtpmail-smtp-service) |
15345 | 518 response-code |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
519 greeting |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
520 process-buffer |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
521 (supported-extensions '())) |
15345 | 522 (unwind-protect |
523 (catch 'done | |
524 ;; get or create the trace buffer | |
525 (setq process-buffer | |
526 (get-buffer-create (format "*trace of SMTP session to %s*" host))) | |
527 | |
528 ;; clear the trace buffer of old output | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
529 (with-current-buffer process-buffer |
15345 | 530 (erase-buffer)) |
531 | |
532 ;; open the connection to the server | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
533 (setq process (smtpmail-open-stream process-buffer host port)) |
15345 | 534 (and (null process) (throw 'done nil)) |
535 | |
536 ;; set the send-filter | |
537 (set-process-filter process 'smtpmail-process-filter) | |
538 | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
539 (with-current-buffer process-buffer |
22037
cb95bfcd442a
(smtpmail-via-smtp): Speciy process coding system.
Richard M. Stallman <rms@gnu.org>
parents:
21862
diff
changeset
|
540 (set-buffer-process-coding-system 'raw-text-unix 'raw-text-unix) |
15345 | 541 (make-local-variable 'smtpmail-read-point) |
542 (setq smtpmail-read-point (point-min)) | |
543 | |
544 | |
545 (if (or (null (car (setq greeting (smtpmail-read-response process)))) | |
546 (not (integerp (car greeting))) | |
547 (>= (car greeting) 400)) | |
548 (throw 'done nil) | |
549 ) | |
550 | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
551 (let ((do-ehlo t) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
552 (do-starttls t)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
553 (while do-ehlo |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
554 ;; EHLO |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
555 (smtpmail-send-command process (format "EHLO %s" (smtpmail-fqdn))) |
15345 | 556 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
557 (if (or (null (car (setq response-code |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
558 (smtpmail-read-response process)))) |
15345 | 559 (not (integerp (car response-code))) |
560 (>= (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
|
561 (progn |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
562 ;; HELO |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
563 (smtpmail-send-command |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
564 process (format "HELO %s" (smtpmail-fqdn))) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
565 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
566 (if (or (null (car (setq response-code |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
567 (smtpmail-read-response process)))) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
568 (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
|
569 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
570 (throw 'done nil))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
571 (dolist (line (cdr (cdr response-code))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
572 (let ((name (mapcar (lambda (s) (intern (downcase s))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
573 (split-string (substring line 4) "[ ]")))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
574 (and (eq (length name) 1) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
575 (setq name (car name))) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
576 (and name |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
577 (cond ((memq (if (consp name) (car name) name) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
578 '(verb xvrb 8bitmime onex xone |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
579 expn size dsn etrn |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
580 enhancedstatuscodes |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
581 help xusr |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
582 auth=login auth starttls)) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
583 (setq supported-extensions |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
584 (cons name supported-extensions))) |
37598
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
585 (smtpmail-warn-about-unknown-extensions |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
586 (message "Unknown extension %s" name))))))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
587 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
588 (if (and do-starttls |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
589 (smtpmail-find-credentials smtpmail-starttls-credentials host port) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
590 (member 'starttls supported-extensions) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
591 (process-id process)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
592 (progn |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
593 (smtpmail-send-command process (format "STARTTLS")) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
594 (if (or (null (car (setq response-code (smtpmail-read-response process)))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
595 (not (integerp (car response-code))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
596 (>= (car response-code) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
597 (throw 'done nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
598 (starttls-negotiate process) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
599 (setq do-starttls nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
600 (setq do-ehlo nil)))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
601 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
602 (smtpmail-try-auth-methods process supported-extensions host port) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
603 |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
604 (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
|
605 (member 'xone supported-extensions)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
606 (progn |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
607 (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
|
608 (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
|
609 (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
|
610 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
611 (throw 'done nil)))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
612 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
613 (if (and smtpmail-debug-verb |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
614 (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
|
615 (member 'xvrb supported-extensions))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
616 (progn |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
617 (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
|
618 (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
|
619 (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
|
620 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
621 (throw 'done nil)))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
622 |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
623 (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
|
624 (progn |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
625 (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
|
626 (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
|
627 (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
|
628 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
629 (throw 'done nil)))) |
15345 | 630 |
631 ;; MAIL FROM: <sender> | |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
632 (let ((size-part |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
633 (if (or (member 'size supported-extensions) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
634 (assoc 'size supported-extensions)) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
635 (format " SIZE=%d" |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
636 (with-current-buffer smtpmail-text-buffer |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
637 ;; size estimate: |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
638 (+ (- (point-max) (point-min)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
639 ;; 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
|
640 ;; 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
|
641 (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
|
642 ;; 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
|
643 ;; 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
|
644 ;; 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
|
645 ;; those two bytes anyway: |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
646 2))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
647 "")) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
648 (body-part |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
649 (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
|
650 ;; FIXME: |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
651 ;; 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
|
652 ;; 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
|
653 ;; 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
|
654 ;; 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
|
655 ;; 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
|
656 ;; 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
|
657 ;; 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
|
658 ;; 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
|
659 ;; 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
|
660 ;; 8BITMIME. |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
661 (if nil |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
662 " BODY=8BITMIME" |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
663 "") |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
664 ""))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
665 ; (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
|
666 (smtpmail-send-command process (format "MAIL FROM: <%s>%s%s" |
40033
ba4d3133ad27
(smtpmail-via-smtp): Use mail-envelope-from if set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38725
diff
changeset
|
667 (or mail-envelope-from |
ba4d3133ad27
(smtpmail-via-smtp): Use mail-envelope-from if set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38725
diff
changeset
|
668 user-mail-address) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
669 size-part |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
670 body-part)) |
15345 | 671 |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
672 (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
|
673 (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
|
674 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
675 (throw 'done nil) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
676 )) |
15345 | 677 |
678 ;; RCPT TO: <recipient> | |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
679 (let ((n 0)) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
680 (while (not (null (nth n recipient))) |
37800
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
681 (smtpmail-send-command process (format "RCPT TO: <%s>" (smtpmail-maybe-append-domain (nth n recipient)))) |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
682 (setq n (1+ n)) |
15345 | 683 |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
684 (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
|
685 (if (or (null (car response-code)) |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
686 (not (integerp (car response-code))) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
687 (>= (car response-code) 400)) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
688 (throw 'done nil) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
689 ) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
690 )) |
15345 | 691 |
692 ;; DATA | |
693 (smtpmail-send-command process "DATA") | |
694 | |
695 (if (or (null (car (setq response-code (smtpmail-read-response process)))) | |
696 (not (integerp (car response-code))) | |
697 (>= (car response-code) 400)) | |
698 (throw 'done nil) | |
699 ) | |
700 | |
701 ;; Mail contents | |
702 (smtpmail-send-data process smtpmail-text-buffer) | |
703 | |
704 ;;DATA end "." | |
705 (smtpmail-send-command process ".") | |
706 | |
707 (if (or (null (car (setq response-code (smtpmail-read-response process)))) | |
708 (not (integerp (car response-code))) | |
709 (>= (car response-code) 400)) | |
710 (throw 'done nil) | |
711 ) | |
712 | |
713 ;;QUIT | |
714 ; (smtpmail-send-command process "QUIT") | |
715 ; (and (null (car (smtpmail-read-response process))) | |
716 ; (throw 'done nil)) | |
717 t )) | |
718 (if process | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
719 (with-current-buffer (process-buffer process) |
15345 | 720 (smtpmail-send-command process "QUIT") |
721 (smtpmail-read-response process) | |
722 | |
723 ; (if (or (null (car (setq response-code (smtpmail-read-response process)))) | |
724 ; (not (integerp (car response-code))) | |
725 ; (>= (car response-code) 400)) | |
726 ; (throw 'done nil) | |
727 ; ) | |
728 (delete-process process)))))) | |
729 | |
730 | |
731 (defun smtpmail-process-filter (process output) | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
732 (with-current-buffer (process-buffer process) |
15345 | 733 (goto-char (point-max)) |
734 (insert output))) | |
735 | |
736 (defun smtpmail-read-response (process) | |
737 (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
|
738 (response-strings nil) |
15345 | 739 (response-continue t) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
740 (return-value '(nil ())) |
15345 | 741 match-end) |
742 | |
743 (while response-continue | |
15454
85313b347ed9
(smtpmail-read-response): Goto smtpmail-read-point
Richard M. Stallman <rms@gnu.org>
parents:
15453
diff
changeset
|
744 (goto-char smtpmail-read-point) |
15345 | 745 (while (not (search-forward "\r\n" nil t)) |
746 (accept-process-output process) | |
747 (goto-char smtpmail-read-point)) | |
748 | |
749 (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
|
750 (setq response-strings |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
751 (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
|
752 response-strings)) |
15345 | 753 |
754 (goto-char smtpmail-read-point) | |
755 (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
|
756 (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
|
757 (end (match-end 0))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
758 (if smtpmail-debug-info |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
759 (message "%s" (car response-strings))) |
15345 | 760 |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
761 (setq smtpmail-read-point match-end) |
15345 | 762 |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
763 ;; 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
|
764 (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
|
765 nil |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
766 (setq response-continue nil) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
767 (setq return-value |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
768 (cons (string-to-int |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
769 (buffer-substring begin end)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
770 (nreverse response-strings))))) |
15345 | 771 |
772 (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
|
773 (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
|
774 (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
|
775 (setq smtpmail-read-point match-end) |
15345 | 776 (setq response-continue t)) |
777 (progn | |
778 (setq smtpmail-read-point match-end) | |
779 (setq response-continue nil) | |
780 (setq return-value | |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
781 (cons nil (nreverse response-strings))) |
15345 | 782 ) |
783 ))) | |
784 (setq smtpmail-read-point match-end) | |
785 return-value)) | |
786 | |
787 | |
788 (defun smtpmail-send-command (process command) | |
789 (goto-char (point-max)) | |
790 (if (= (aref command 0) ?P) | |
791 (insert "PASS <omitted>\r\n") | |
792 (insert command "\r\n")) | |
793 (setq smtpmail-read-point (point)) | |
794 (process-send-string process command) | |
795 (process-send-string process "\r\n")) | |
796 | |
797 (defun smtpmail-send-data-1 (process data) | |
798 (goto-char (point-max)) | |
799 | |
24773 | 800 (if (and (multibyte-string-p data) |
801 smtpmail-code-conv-from) | |
802 (setq data (string-as-multibyte | |
803 (encode-coding-string data smtpmail-code-conv-from)))) | |
15345 | 804 |
805 (if smtpmail-debug-info | |
806 (insert data "\r\n")) | |
807 | |
808 (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
|
809 ;; 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
|
810 (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
|
811 (process-send-string process ".")) |
15345 | 812 (process-send-string process data) |
813 (process-send-string process "\r\n") | |
814 ) | |
815 | |
816 (defun smtpmail-send-data (process buffer) | |
817 (let | |
818 ((data-continue t) | |
819 (sending-data nil) | |
820 this-line | |
821 this-line-end) | |
822 | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
823 (with-current-buffer buffer |
15345 | 824 (goto-char (point-min))) |
825 | |
826 (while data-continue | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
827 (with-current-buffer buffer |
15345 | 828 (beginning-of-line) |
829 (setq this-line (point)) | |
830 (end-of-line) | |
831 (setq this-line-end (point)) | |
832 (setq sending-data nil) | |
833 (setq sending-data (buffer-substring this-line this-line-end)) | |
834 (if (/= (forward-line 1) 0) | |
835 (setq data-continue nil))) | |
836 | |
837 (smtpmail-send-data-1 process sending-data) | |
838 ) | |
839 ) | |
840 ) | |
841 | |
842 | |
843 (defun smtpmail-deduce-address-list (smtpmail-text-buffer header-start header-end) | |
844 "Get address list suitable for smtp RCPT TO: <address>." | |
24663
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
845 (unwind-protect |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
846 (with-current-buffer smtpmail-address-buffer |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
847 (erase-buffer) |
24663
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
848 (let |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
849 ((case-fold-search t) |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
850 (simple-address-list "") |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
851 this-line |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
852 this-line-end |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
853 addr-regexp) |
15345 | 854 (insert-buffer-substring smtpmail-text-buffer header-start header-end) |
855 (goto-char (point-min)) | |
15648
2feeabc94834
(smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents:
15595
diff
changeset
|
856 ;; 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
|
857 (save-excursion |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
858 (setq addr-regexp |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
859 (if (re-search-forward "^Resent-\\(to\\|cc\\|bcc\\):" |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
860 header-end t) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
861 "^Resent-\\(to\\|cc\\|bcc\\):" |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
862 "^\\(To:\\|Cc:\\|Bcc:\\)"))) |
15648
2feeabc94834
(smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents:
15595
diff
changeset
|
863 |
2feeabc94834
(smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents:
15595
diff
changeset
|
864 (while (re-search-forward addr-regexp header-end t) |
15345 | 865 (replace-match "") |
866 (setq this-line (match-beginning 0)) | |
867 (forward-line 1) | |
868 ;; get any continuation lines | |
869 (while (and (looking-at "^[ \t]+") (< (point) header-end)) | |
870 (forward-line 1)) | |
871 (setq this-line-end (point-marker)) | |
872 (setq simple-address-list | |
873 (concat simple-address-list " " | |
874 (mail-strip-quoted-names (buffer-substring this-line this-line-end)))) | |
875 ) | |
876 (erase-buffer) | |
41497
608d7b92d289
Simplify previous change.
Richard M. Stallman <rms@gnu.org>
parents:
41492
diff
changeset
|
877 (insert " " simple-address-list "\n") |
15345 | 878 (subst-char-in-region (point-min) (point-max) 10 ? t);; newline --> blank |
879 (subst-char-in-region (point-min) (point-max) ?, ? t);; comma --> blank | |
880 (subst-char-in-region (point-min) (point-max) 9 ? t);; tab --> blank | |
881 | |
882 (goto-char (point-min)) | |
883 ;; tidyness in case hook is not robust when it looks at this | |
884 (while (re-search-forward "[ \t]+" header-end t) (replace-match " ")) | |
885 | |
886 (goto-char (point-min)) | |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
887 (let (recipient-address-list) |
15451
89c1e7fe879a
(smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents:
15372
diff
changeset
|
888 (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
|
889 (backward-char 1) |
15451
89c1e7fe879a
(smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents:
15372
diff
changeset
|
890 (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
|
891 recipient-address-list)) |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
892 ) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
893 (setq smtpmail-recipient-address-list recipient-address-list)) |
15345 | 894 |
895 ) | |
24663
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
896 ) |
15345 | 897 ) |
898 ) | |
899 | |
900 | |
901 (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
|
902 "Delete [Resent-]BCC: and their continuation lines from the header area. |
15345 | 903 There may be multiple BCC: lines, and each may have arbitrarily |
904 many continuation lines." | |
905 (let ((case-fold-search t)) | |
24455 | 906 (save-excursion |
907 (goto-char (point-min)) | |
908 ;; iterate over all BCC: lines | |
909 (while (re-search-forward "^\\(RESENT-\\)?BCC:" header-end t) | |
910 (delete-region (match-beginning 0) | |
911 (progn (forward-line 1) (point))) | |
912 ;; get rid of any continuation lines | |
913 (while (and (looking-at "^[ \t].*\n") (< (point) header-end)) | |
914 (replace-match "")))))) | |
15345 | 915 |
916 | |
917 (provide 'smtpmail) | |
918 | |
17517 | 919 ;;; smtpmail.el ends here |