Mercurial > emacs
annotate lisp/mail/smtpmail.el @ 48166:f4093f55e9c2
(POLLING_PROBLEM_IN_SELECT): Defined.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 06 Nov 2002 04:57:48 +0000 |
parents | b9705a05fa60 |
children | 03ac1463ec5e |
rev | line source |
---|---|
17517 | 1 ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail |
15345 | 2 |
47225 | 3 ;; Copyright (C) 1995, 1996, 2001, 2002 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' |
44864
c18dd95f6962
(smtpmail-queue-counter): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
42225
diff
changeset
|
38 ;;(setq message-send-mail-function 'smtpmail-send-it) ; if you use message/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 |
44868
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
43 ;;(setq smtpmail-auth-credentials ; or use ~/.authinfo |
41221
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 |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
48 ;; To queue mail, set smtpmail-queue-mail to t and use |
18094 | 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) | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
69 (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
|
70 (autoload 'starttls-negotiate "starttls") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
71 (autoload 'mail-strip-quoted-names "mail-utils") |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
72 (autoload 'message-make-date "message") |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
73 (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
|
74 (autoload 'rfc2104-hash "rfc2104") |
44868
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
75 (autoload 'netrc-parse "netrc") |
45179
6ff2c20da16e
(netrc-machine, netrc-get): Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
44883
diff
changeset
|
76 (autoload 'netrc-machine "netrc") |
6ff2c20da16e
(netrc-machine, netrc-get): Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
44883
diff
changeset
|
77 (autoload 'netrc-get "netrc") |
15345 | 78 |
79 ;;; | |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
80 (defgroup smtpmail nil |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
81 "SMTP protocol for sending mail." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
82 :group 'mail) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
83 |
15345 | 84 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
85 (defcustom smtpmail-default-smtp-server nil |
47396
d7fa9253971f
(smtpmail-default-smtp-server): Doc fix.
Simon Josefsson <jas@extundo.com>
parents:
47225
diff
changeset
|
86 "*Specify default SMTP server. |
d7fa9253971f
(smtpmail-default-smtp-server): Doc fix.
Simon Josefsson <jas@extundo.com>
parents:
47225
diff
changeset
|
87 This only has effect if you specify it before loading the smtpmail library." |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
88 :type '(choice (const nil) string) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
89 :group 'smtpmail) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
90 |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
91 (defcustom smtpmail-smtp-server |
15451
89c1e7fe879a
(smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents:
15372
diff
changeset
|
92 (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
|
93 "*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
|
94 :type '(choice (const nil) string) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
95 :group 'smtpmail) |
15345 | 96 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
97 (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
|
98 "*SMTP service port number. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
99 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
|
100 :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
|
101 :group 'smtpmail) |
15345 | 102 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
103 (defcustom smtpmail-local-domain nil |
15345 | 104 "*Local domain name without a host name. |
105 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
|
106 don't define this value." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
107 :type '(choice (const nil) string) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
108 :group 'smtpmail) |
15345 | 109 |
26028
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
110 (defcustom smtpmail-sendto-domain nil |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
111 "*Local domain name without a host name. |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
112 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
|
113 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
|
114 \(Some configurations of sendmail require this.) |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
115 |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
116 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
|
117 Sending failed; SMTP protocol error |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
118 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
|
119 buffer includes an exchange like: |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
120 RCPT TO: <someone> |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
121 501 <someone>: recipient address must contain a domain |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
122 " |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
123 :type '(choice (const nil) string) |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
124 :group 'smtpmail) |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
125 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
126 (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
|
127 "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
|
128 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
|
129 be verbose as well." |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
130 :type 'boolean |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
131 :group 'smtpmail) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
132 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
133 (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
|
134 "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
|
135 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
|
136 :type 'boolean |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
137 :group 'smtpmail) |
15345 | 138 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
139 (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
|
140 "*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
|
141 :type 'boolean |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
142 :group 'smtpmail) |
15345 | 143 |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
144 (defcustom smtpmail-queue-mail nil |
18094 | 145 "*Specify if mail is queued (if t) or sent immediately (if nil). |
146 If queued, it is stored in the directory `smtpmail-queue-dir' | |
147 and sent with `smtpmail-send-queued-mail'." | |
148 :type 'boolean | |
149 :group 'smtpmail) | |
150 | |
151 (defcustom smtpmail-queue-dir "~/Mail/queued-mail/" | |
152 "*Directory where `smtpmail.el' stores queued mail." | |
153 :type 'directory | |
154 :group 'smtpmail) | |
155 | |
44868
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
156 (defcustom smtpmail-auth-credentials "~/.authinfo" |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
157 "Specify username and password for servers, directly or via .netrc file. |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
158 This variable can either be a filename pointing to a file in netrc(5) |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
159 format, or list of four-element lists that contain, in order, |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
160 `servername' (a string), `port' (an integer), `user' (a string) and |
44868
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
161 `password' (a string, or nil to query the user when needed). If you |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
162 need to enter a `realm' too, add it to the user string, so that it |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
163 looks like `user@realm'." |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
164 :type '(choice file |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
165 (repeat (list (string :tag "Server") |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
166 (integer :tag "Port") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
167 (string :tag "Username") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
168 (choice (const :tag "Query when needed" nil) |
44868
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
169 (string :tag "Password"))))) |
45204
a025c8bb9569
(smtpmail-send-it): Use user-mail-address from
Simon Josefsson <jas@extundo.com>
parents:
45179
diff
changeset
|
170 :version "21.4" |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
171 :group 'smtpmail) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
172 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
173 (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
|
174 "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
|
175 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
|
176 `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
|
177 :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
|
178 (integer :tag "Port") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
179 (file :tag "Key") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
180 (file :tag "Certificate"))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
181 :version "21.1" |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
182 :group 'smtpmail) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
183 |
37598
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
184 (defcustom smtpmail-warn-about-unknown-extensions nil |
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
185 "*If set, print warnings about unknown SMTP extensions. |
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
186 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
|
187 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
|
188 :type 'boolean |
37600
20c37aac51cd
(smtpmail-warn-about-unknown-extensions): Add :version.
Gerd Moellmann <gerd@gnu.org>
parents:
37598
diff
changeset
|
189 :version "21.1" |
37598
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
190 :group 'smtpmail) |
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
191 |
18094 | 192 (defvar smtpmail-queue-index-file "index" |
193 "File name of queued mail index, | |
194 This is relative to `smtpmail-queue-dir'.") | |
195 | |
23444
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
196 (defvar smtpmail-address-buffer) |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
197 (defvar smtpmail-recipient-address-list) |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
198 |
44864
c18dd95f6962
(smtpmail-queue-counter): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
42225
diff
changeset
|
199 (defvar smtpmail-queue-counter 0) |
c18dd95f6962
(smtpmail-queue-counter): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
42225
diff
changeset
|
200 |
23444
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
201 ;; Buffer-local variable. |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
202 (defvar smtpmail-read-point) |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
203 |
18094 | 204 (defvar smtpmail-queue-index (concat smtpmail-queue-dir |
205 smtpmail-queue-index-file)) | |
206 | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
207 (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
|
208 "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
|
209 |
15345 | 210 ;;; |
211 ;;; | |
212 ;;; | |
213 | |
45252
ee1b06064fbb
(smtpmail-mail-address): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45204
diff
changeset
|
214 (defvar smtpmail-mail-address nil |
ee1b06064fbb
(smtpmail-mail-address): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45204
diff
changeset
|
215 "Value of `user-mail-address' in ambient buffer.") |
ee1b06064fbb
(smtpmail-mail-address): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45204
diff
changeset
|
216 |
23142
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
217 ;;;###autoload |
15345 | 218 (defun smtpmail-send-it () |
219 (let ((errbuf (if mail-interactive | |
220 (generate-new-buffer " smtpmail errors") | |
221 0)) | |
222 (tembuf (generate-new-buffer " smtpmail temp")) | |
223 (case-fold-search nil) | |
224 delimline | |
24773 | 225 (mailbuf (current-buffer)) |
45252
ee1b06064fbb
(smtpmail-mail-address): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45204
diff
changeset
|
226 (smtpmail-mail-address user-mail-address) |
24773 | 227 (smtpmail-code-conv-from |
228 (if enable-multibyte-characters | |
229 (let ((sendmail-coding-system smtpmail-code-conv-from)) | |
230 (select-message-coding-system))))) | |
15345 | 231 (unwind-protect |
232 (save-excursion | |
233 (set-buffer tembuf) | |
234 (erase-buffer) | |
235 (insert-buffer-substring mailbuf) | |
236 (goto-char (point-max)) | |
237 ;; require one newline at the end. | |
238 (or (= (preceding-char) ?\n) | |
239 (insert ?\n)) | |
240 ;; 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
|
241 (mail-sendmail-undelimit-header) |
15345 | 242 (setq delimline (point-marker)) |
15451
89c1e7fe879a
(smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents:
15372
diff
changeset
|
243 ;; (sendmail-synch-aliases) |
15345 | 244 (if mail-aliases |
245 (expand-mail-aliases (point-min) delimline)) | |
246 (goto-char (point-min)) | |
247 ;; ignore any blank lines in the header | |
248 (while (and (re-search-forward "\n\n\n*" delimline t) | |
249 (< (point) delimline)) | |
250 (replace-match "\n")) | |
251 (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
|
252 ;; 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
|
253 ;; 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
|
254 ;; is done correctly in smtpmail-deduce-address-list. |
15345 | 255 ;; Don't send out a blank subject line |
256 (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
|
257 (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
|
258 (replace-match "") |
dfb671ba22f8
(smtpmail-send-it): Deleted all code related to Resent-To: processing.
Richard M. Stallman <rms@gnu.org>
parents:
20058
diff
changeset
|
259 ;; 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
|
260 (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
|
261 (= (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
|
262 (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
|
263 ;; 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
|
264 ;; 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
|
265 (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
|
266 (if (not (re-search-forward "^From:" delimline t)) |
45252
ee1b06064fbb
(smtpmail-mail-address): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45204
diff
changeset
|
267 (let* ((login smtpmail-mail-address) |
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
|
268 (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
|
269 (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
|
270 (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
|
271 (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
|
272 (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
|
273 (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
|
274 ;; 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
|
275 ;; 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
|
276 (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
|
277 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
|
278 (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
|
279 ;; 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
|
280 (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
|
281 (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
|
282 (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
|
283 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
|
284 (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
|
285 (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
|
286 (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
|
287 ((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
|
288 (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
|
289 (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
|
290 (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
|
291 (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
|
292 (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
|
293 ;; 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
|
294 ;; 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
|
295 ;; 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
|
296 (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
|
297 (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
|
298 ;; ... 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
|
299 ;; 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
|
300 (goto-char fullname-start) |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
301 (while (re-search-forward |
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
|
302 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)" |
6f41e17b3452
(smtpmail-send-it): Don't handle FCC fields until after determining FROM field.
Richard M. Stallman <rms@gnu.org>
parents:
15451
diff
changeset
|
303 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
|
304 (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
|
305 (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
|
306 (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
|
307 ((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
|
308 (insert "From: " login "\n"))))) |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
309 ;; 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
|
310 (goto-char (point-min)) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
311 (unless (re-search-forward "^Message-Id:" delimline t) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
312 (insert "Message-Id: " (message-make-message-id) "\n")) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
313 ;; 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
|
314 (goto-char (point-min)) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
315 (unless (re-search-forward "^Date:" delimline t) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
316 (insert "Date: " (message-make-date) "\n")) |
15345 | 317 ;; Insert an extra newline if we need it to work around |
318 ;; Sun's bug that swallows newlines. | |
319 (goto-char (1+ delimline)) | |
320 (if (eval mail-mailer-swallows-blank-line) | |
321 (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
|
322 ;; 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
|
323 (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
|
324 (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
|
325 (mail-do-fcc delimline)) |
15345 | 326 (if mail-interactive |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
327 (with-current-buffer errbuf |
15345 | 328 (erase-buffer)))) |
329 ;; | |
330 ;; | |
331 ;; | |
332 (setq smtpmail-address-buffer (generate-new-buffer "*smtp-mail*")) | |
333 (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
|
334 (smtpmail-deduce-address-list tembuf (point-min) delimline)) |
15345 | 335 (kill-buffer smtpmail-address-buffer) |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
336 |
15345 | 337 (smtpmail-do-bcc delimline) |
18094 | 338 ; Send or queue |
339 (if (not smtpmail-queue-mail) | |
340 (if (not (null smtpmail-recipient-address-list)) | |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
341 (if (not (smtpmail-via-smtp |
18094 | 342 smtpmail-recipient-address-list tembuf)) |
343 (error "Sending failed; SMTP protocol error")) | |
344 (error "Sending failed; no recipients")) | |
47436
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
345 (let* ((file-data |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
346 (expand-file-name |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
347 (format "%s_%i" |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
348 (format-time-string "%Y-%m-%d_%H:%M:%S") |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
349 (setq smtpmail-queue-counter |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
350 (1+ smtpmail-queue-counter))) |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
351 smtpmail-queue-dir)) |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
352 (file-data (convert-standard-filename file-data)) |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
353 (file-elisp (concat file-data ".el")) |
18094 | 354 (buffer-data (create-file-buffer file-data)) |
355 (buffer-elisp (create-file-buffer file-elisp)) | |
356 (buffer-scratch "*queue-mail*")) | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
357 (with-current-buffer buffer-data |
18094 | 358 (erase-buffer) |
359 (insert-buffer tembuf) | |
360 (write-file file-data) | |
361 (set-buffer buffer-elisp) | |
362 (erase-buffer) | |
363 (insert (concat | |
364 "(setq smtpmail-recipient-address-list '" | |
365 (prin1-to-string smtpmail-recipient-address-list) | |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
366 ")\n")) |
18094 | 367 (write-file file-elisp) |
368 (set-buffer (generate-new-buffer buffer-scratch)) | |
369 (insert (concat file-data "\n")) | |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
370 (append-to-file (point-min) |
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
371 (point-max) |
18094 | 372 smtpmail-queue-index) |
373 ) | |
374 (kill-buffer buffer-scratch) | |
375 (kill-buffer buffer-data) | |
376 (kill-buffer buffer-elisp)))) | |
15345 | 377 (kill-buffer tembuf) |
378 (if (bufferp errbuf) | |
379 (kill-buffer errbuf))))) | |
380 | |
18094 | 381 (defun smtpmail-send-queued-mail () |
382 "Send mail that was queued as a result of setting `smtpmail-queue-mail'." | |
383 (interactive) | |
42225
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
384 (with-temp-buffer |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
385 ;;; 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
|
386 ;;; mail, send it, etc... |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
387 (let ((file-msg "")) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
388 (insert-file-contents smtpmail-queue-index) |
18094 | 389 (beginning-of-buffer) |
390 (while (not (eobp)) | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
391 (setq file-msg (buffer-substring (point) (line-end-position))) |
18094 | 392 (load file-msg) |
41921
de4a90cd0a5f
(smtpmail-send-queued-mail): Insert the enqueued messages literally.
Eli Zaretskii <eliz@gnu.org>
parents:
41716
diff
changeset
|
393 ;; 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
|
394 ;; 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
|
395 ;; encoding wrongly. |
42225
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
396 (with-temp-buffer |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
397 (let ((coding-system-for-read 'no-conversion)) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
398 (insert-file-contents file-msg)) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
399 (if (not (null smtpmail-recipient-address-list)) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
400 (if (not (smtpmail-via-smtp smtpmail-recipient-address-list |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
401 (current-buffer))) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
402 (error "Sending failed; SMTP protocol error")) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
403 (error "Sending failed; no recipients"))) |
18094 | 404 (delete-file file-msg) |
405 (delete-file (concat file-msg ".el")) | |
42225
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
406 (kill-line 1)) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
407 (write-region (point-min) (point-max) smtpmail-queue-index)))) |
15345 | 408 |
409 ;(defun smtpmail-via-smtp (host,port,sender,destination,smtpmail-text-buffer) | |
410 | |
411 (defun smtpmail-fqdn () | |
412 (if smtpmail-local-domain | |
413 (concat (system-name) "." smtpmail-local-domain) | |
414 (system-name))) | |
415 | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
416 (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
|
417 (nth 0 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
418 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
419 (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
|
420 (nth 1 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
421 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
422 (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
|
423 (nth 2 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
424 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
425 (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
|
426 (nth 2 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
427 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
428 (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
|
429 (nth 3 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
430 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
431 (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
|
432 (nth 3 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
433 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
434 (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
|
435 (catch 'done |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
436 (let ((l cred) el) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
437 (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
|
438 (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
|
439 (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
|
440 (throw 'done el)))))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
441 |
37800
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
442 (defun smtpmail-maybe-append-domain (recipient) |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
443 (if (or (not smtpmail-sendto-domain) |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
444 (string-match "@" recipient)) |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
445 recipient |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
446 (concat recipient "@" smtpmail-sendto-domain))) |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
447 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
448 (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
|
449 (let ((result nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
450 (dolist (el2 list2) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
451 (when (memq el2 list1) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
452 (push el2 result))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
453 (nreverse result))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
454 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
455 (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
|
456 (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
|
457 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
|
458 (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
|
459 (call-process "starttls") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
460 (error nil)))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
461 ;; The normal case. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
462 (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
|
463 (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
|
464 (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
|
465 (starttls-extra-args |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
466 (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
|
467 (file-regular-p |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
468 (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
|
469 (file-regular-p |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
470 (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
|
471 (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
|
472 (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
|
473 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
474 (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
|
475 (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
|
476 (mech (car (smtpmail-intersection smtpmail-auth-supported mechs))) |
44868
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
477 (cred (if (stringp smtpmail-auth-credentials) |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
478 (let* ((netrc (netrc-parse smtpmail-auth-credentials)) |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
479 (hostentry (netrc-machine |
44868
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
480 netrc host (format "%s" (or port "smtp")) |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
481 "smtp"))) |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
482 (when hostentry |
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
483 (list host port |
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
484 (netrc-get hostentry "login") |
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
485 (netrc-get hostentry "password")))) |
44868
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
486 (smtpmail-find-credentials |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
487 smtpmail-auth-credentials host port))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
488 (passwd (when cred |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
489 (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
|
490 (read-passwd |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
491 (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
|
492 (smtpmail-cred-server cred) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
493 (smtpmail-cred-port cred)))))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
494 ret) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
495 (when cred |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
496 (cond |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
497 ((eq mech 'cram-md5) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
498 (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
|
499 (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
|
500 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
501 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
502 (throw 'done nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
503 (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
|
504 (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
|
505 (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
|
506 (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
|
507 (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
|
508 (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
|
509 (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
|
510 (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
|
511 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
512 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
513 (throw 'done nil))))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
514 ((eq mech 'login) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
515 (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
|
516 (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
|
517 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
518 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
519 (throw 'done nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
520 (smtpmail-send-command |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
521 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
|
522 (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
|
523 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
524 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
525 (throw 'done nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
526 (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
|
527 (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
|
528 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
529 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
530 (throw 'done nil))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
531 (t |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
532 (error "Mechanism %s not implemented" mech))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
533 ;; Remember the password. |
44868
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
534 (when (and (not (stringp smtpmail-auth-credentials)) |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
535 (null (smtpmail-cred-passwd cred))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
536 (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
|
537 |
15345 | 538 (defun smtpmail-via-smtp (recipient smtpmail-text-buffer) |
539 (let ((process nil) | |
23142
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
540 (host (or smtpmail-smtp-server |
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
541 (error "`smtpmail-smtp-server' not defined"))) |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
542 (port smtpmail-smtp-service) |
47837
b9705a05fa60
* mail/sendmail.el (mail-envelope-from): New option `header' to
Simon Josefsson <jas@extundo.com>
parents:
47672
diff
changeset
|
543 (envelope-from (mail-envelope-from)) |
15345 | 544 response-code |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
545 greeting |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
546 process-buffer |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
547 (supported-extensions '())) |
15345 | 548 (unwind-protect |
549 (catch 'done | |
550 ;; get or create the trace buffer | |
551 (setq process-buffer | |
552 (get-buffer-create (format "*trace of SMTP session to %s*" host))) | |
553 | |
554 ;; clear the trace buffer of old output | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
555 (with-current-buffer process-buffer |
15345 | 556 (erase-buffer)) |
557 | |
558 ;; 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
|
559 (setq process (smtpmail-open-stream process-buffer host port)) |
15345 | 560 (and (null process) (throw 'done nil)) |
561 | |
562 ;; set the send-filter | |
563 (set-process-filter process 'smtpmail-process-filter) | |
564 | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
565 (with-current-buffer process-buffer |
22037
cb95bfcd442a
(smtpmail-via-smtp): Speciy process coding system.
Richard M. Stallman <rms@gnu.org>
parents:
21862
diff
changeset
|
566 (set-buffer-process-coding-system 'raw-text-unix 'raw-text-unix) |
15345 | 567 (make-local-variable 'smtpmail-read-point) |
568 (setq smtpmail-read-point (point-min)) | |
569 | |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
570 |
15345 | 571 (if (or (null (car (setq greeting (smtpmail-read-response process)))) |
572 (not (integerp (car greeting))) | |
573 (>= (car greeting) 400)) | |
574 (throw 'done nil) | |
575 ) | |
576 | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
577 (let ((do-ehlo t) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
578 (do-starttls t)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
579 (while do-ehlo |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
580 ;; EHLO |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
581 (smtpmail-send-command process (format "EHLO %s" (smtpmail-fqdn))) |
15345 | 582 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
583 (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
|
584 (smtpmail-read-response process)))) |
15345 | 585 (not (integerp (car response-code))) |
586 (>= (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
|
587 (progn |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
588 ;; HELO |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
589 (smtpmail-send-command |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
590 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
|
591 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
592 (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
|
593 (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
|
594 (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
|
595 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
596 (throw 'done nil))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
597 (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
|
598 (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
|
599 (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
|
600 (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
|
601 (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
|
602 (and name |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
603 (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
|
604 '(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
|
605 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
|
606 enhancedstatuscodes |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
607 help xusr |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
608 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
|
609 (setq supported-extensions |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
610 (cons name supported-extensions))) |
37598
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
611 (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
|
612 (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
|
613 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
614 (if (and do-starttls |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
615 (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
|
616 (member 'starttls supported-extensions) |
47672
666b84b52b82
(smtpmail-via-smtp): Only negotiate starttls on
Simon Josefsson <jas@extundo.com>
parents:
47436
diff
changeset
|
617 (numberp (process-id process))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
618 (progn |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
619 (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
|
620 (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
|
621 (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
|
622 (>= (car response-code) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
623 (throw 'done nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
624 (starttls-negotiate process) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
625 (setq do-starttls nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
626 (setq do-ehlo nil)))) |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
627 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
628 (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
|
629 |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
630 (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
|
631 (member 'xone supported-extensions)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
632 (progn |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
633 (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
|
634 (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
|
635 (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
|
636 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
637 (throw 'done nil)))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
638 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
639 (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
|
640 (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
|
641 (member 'xvrb supported-extensions))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
642 (progn |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
643 (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
|
644 (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
|
645 (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
|
646 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
647 (throw 'done nil)))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
648 |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
649 (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
|
650 (progn |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
651 (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
|
652 (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
|
653 (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
|
654 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
655 (throw 'done nil)))) |
15345 | 656 |
657 ;; MAIL FROM: <sender> | |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
658 (let ((size-part |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
659 (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
|
660 (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
|
661 (format " SIZE=%d" |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
662 (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
|
663 ;; size estimate: |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
664 (+ (- (point-max) (point-min)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
665 ;; 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
|
666 ;; 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
|
667 (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
|
668 ;; 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
|
669 ;; 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
|
670 ;; 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
|
671 ;; those two bytes anyway: |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
672 2))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
673 "")) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
674 (body-part |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
675 (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
|
676 ;; FIXME: |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
677 ;; 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
|
678 ;; 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
|
679 ;; 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
|
680 ;; 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
|
681 ;; 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
|
682 ;; 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
|
683 ;; 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
|
684 ;; 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
|
685 ;; 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
|
686 ;; 8BITMIME. |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
687 (if nil |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
688 " BODY=8BITMIME" |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
689 "") |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
690 ""))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
691 ; (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
|
692 (smtpmail-send-command process (format "MAIL FROM: <%s>%s%s" |
47837
b9705a05fa60
* mail/sendmail.el (mail-envelope-from): New option `header' to
Simon Josefsson <jas@extundo.com>
parents:
47672
diff
changeset
|
693 (or envelope-from |
45252
ee1b06064fbb
(smtpmail-mail-address): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45204
diff
changeset
|
694 smtpmail-mail-address) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
695 size-part |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
696 body-part)) |
15345 | 697 |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
698 (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
|
699 (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
|
700 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
701 (throw 'done nil) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
702 )) |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
703 |
15345 | 704 ;; RCPT TO: <recipient> |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
705 (let ((n 0)) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
706 (while (not (null (nth n recipient))) |
37800
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
707 (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
|
708 (setq n (1+ n)) |
15345 | 709 |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
710 (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
|
711 (if (or (null (car response-code)) |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
712 (not (integerp (car response-code))) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
713 (>= (car response-code) 400)) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
714 (throw 'done nil) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
715 ) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
716 )) |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
717 |
15345 | 718 ;; DATA |
719 (smtpmail-send-command process "DATA") | |
720 | |
721 (if (or (null (car (setq response-code (smtpmail-read-response process)))) | |
722 (not (integerp (car response-code))) | |
723 (>= (car response-code) 400)) | |
724 (throw 'done nil) | |
725 ) | |
726 | |
727 ;; Mail contents | |
728 (smtpmail-send-data process smtpmail-text-buffer) | |
729 | |
730 ;;DATA end "." | |
731 (smtpmail-send-command process ".") | |
732 | |
733 (if (or (null (car (setq response-code (smtpmail-read-response process)))) | |
734 (not (integerp (car response-code))) | |
735 (>= (car response-code) 400)) | |
736 (throw 'done nil) | |
737 ) | |
738 | |
739 ;;QUIT | |
740 ; (smtpmail-send-command process "QUIT") | |
741 ; (and (null (car (smtpmail-read-response process))) | |
742 ; (throw 'done nil)) | |
743 t )) | |
744 (if process | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
745 (with-current-buffer (process-buffer process) |
15345 | 746 (smtpmail-send-command process "QUIT") |
747 (smtpmail-read-response process) | |
748 | |
749 ; (if (or (null (car (setq response-code (smtpmail-read-response process)))) | |
750 ; (not (integerp (car response-code))) | |
751 ; (>= (car response-code) 400)) | |
752 ; (throw 'done nil) | |
753 ; ) | |
47117
c6c0e4cc9d0a
(smtpmail-via-smtp): Delete process buffer
Simon Josefsson <jas@extundo.com>
parents:
45252
diff
changeset
|
754 (delete-process process) |
c6c0e4cc9d0a
(smtpmail-via-smtp): Delete process buffer
Simon Josefsson <jas@extundo.com>
parents:
45252
diff
changeset
|
755 (unless smtpmail-debug-info |
c6c0e4cc9d0a
(smtpmail-via-smtp): Delete process buffer
Simon Josefsson <jas@extundo.com>
parents:
45252
diff
changeset
|
756 (kill-buffer process-buffer))))))) |
15345 | 757 |
758 | |
759 (defun smtpmail-process-filter (process output) | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
760 (with-current-buffer (process-buffer process) |
15345 | 761 (goto-char (point-max)) |
762 (insert output))) | |
763 | |
764 (defun smtpmail-read-response (process) | |
765 (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
|
766 (response-strings nil) |
15345 | 767 (response-continue t) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
768 (return-value '(nil ())) |
15345 | 769 match-end) |
770 | |
771 (while response-continue | |
15454
85313b347ed9
(smtpmail-read-response): Goto smtpmail-read-point
Richard M. Stallman <rms@gnu.org>
parents:
15453
diff
changeset
|
772 (goto-char smtpmail-read-point) |
15345 | 773 (while (not (search-forward "\r\n" nil t)) |
774 (accept-process-output process) | |
775 (goto-char smtpmail-read-point)) | |
776 | |
777 (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
|
778 (setq response-strings |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
779 (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
|
780 response-strings)) |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
781 |
15345 | 782 (goto-char smtpmail-read-point) |
783 (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
|
784 (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
|
785 (end (match-end 0))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
786 (if smtpmail-debug-info |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
787 (message "%s" (car response-strings))) |
15345 | 788 |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
789 (setq smtpmail-read-point match-end) |
15345 | 790 |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
791 ;; 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
|
792 (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
|
793 nil |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
794 (setq response-continue nil) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
795 (setq return-value |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
796 (cons (string-to-int |
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
797 (buffer-substring begin end)) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
798 (nreverse response-strings))))) |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
799 |
15345 | 800 (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
|
801 (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
|
802 (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
|
803 (setq smtpmail-read-point match-end) |
15345 | 804 (setq response-continue t)) |
805 (progn | |
806 (setq smtpmail-read-point match-end) | |
807 (setq response-continue nil) | |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
808 (setq return-value |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
809 (cons nil (nreverse response-strings))) |
15345 | 810 ) |
811 ))) | |
812 (setq smtpmail-read-point match-end) | |
813 return-value)) | |
814 | |
815 | |
816 (defun smtpmail-send-command (process command) | |
817 (goto-char (point-max)) | |
818 (if (= (aref command 0) ?P) | |
819 (insert "PASS <omitted>\r\n") | |
820 (insert command "\r\n")) | |
821 (setq smtpmail-read-point (point)) | |
822 (process-send-string process command) | |
823 (process-send-string process "\r\n")) | |
824 | |
825 (defun smtpmail-send-data-1 (process data) | |
826 (goto-char (point-max)) | |
827 | |
24773 | 828 (if (and (multibyte-string-p data) |
829 smtpmail-code-conv-from) | |
830 (setq data (string-as-multibyte | |
831 (encode-coding-string data smtpmail-code-conv-from)))) | |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
832 |
15345 | 833 (if smtpmail-debug-info |
834 (insert data "\r\n")) | |
835 | |
836 (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
|
837 ;; 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
|
838 (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
|
839 (process-send-string process ".")) |
15345 | 840 (process-send-string process data) |
841 (process-send-string process "\r\n") | |
842 ) | |
843 | |
844 (defun smtpmail-send-data (process buffer) | |
845 (let | |
846 ((data-continue t) | |
847 (sending-data nil) | |
848 this-line | |
849 this-line-end) | |
850 | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
851 (with-current-buffer buffer |
15345 | 852 (goto-char (point-min))) |
853 | |
854 (while data-continue | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
855 (with-current-buffer buffer |
15345 | 856 (beginning-of-line) |
857 (setq this-line (point)) | |
858 (end-of-line) | |
859 (setq this-line-end (point)) | |
860 (setq sending-data nil) | |
861 (setq sending-data (buffer-substring this-line this-line-end)) | |
862 (if (/= (forward-line 1) 0) | |
863 (setq data-continue nil))) | |
864 | |
865 (smtpmail-send-data-1 process sending-data) | |
866 ) | |
867 ) | |
868 ) | |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
869 |
15345 | 870 |
871 (defun smtpmail-deduce-address-list (smtpmail-text-buffer header-start header-end) | |
872 "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
|
873 (unwind-protect |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
874 (with-current-buffer smtpmail-address-buffer |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
875 (erase-buffer) |
24663
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
876 (let |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
877 ((case-fold-search t) |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
878 (simple-address-list "") |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
879 this-line |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
880 this-line-end |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
881 addr-regexp) |
15345 | 882 (insert-buffer-substring smtpmail-text-buffer header-start header-end) |
883 (goto-char (point-min)) | |
15648
2feeabc94834
(smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents:
15595
diff
changeset
|
884 ;; 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
|
885 (save-excursion |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
886 (setq addr-regexp |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
887 (if (re-search-forward "^Resent-\\(to\\|cc\\|bcc\\):" |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
888 header-end t) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
889 "^Resent-\\(to\\|cc\\|bcc\\):" |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
890 "^\\(To:\\|Cc:\\|Bcc:\\)"))) |
15648
2feeabc94834
(smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents:
15595
diff
changeset
|
891 |
2feeabc94834
(smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents:
15595
diff
changeset
|
892 (while (re-search-forward addr-regexp header-end t) |
15345 | 893 (replace-match "") |
894 (setq this-line (match-beginning 0)) | |
895 (forward-line 1) | |
896 ;; get any continuation lines | |
897 (while (and (looking-at "^[ \t]+") (< (point) header-end)) | |
898 (forward-line 1)) | |
899 (setq this-line-end (point-marker)) | |
900 (setq simple-address-list | |
901 (concat simple-address-list " " | |
902 (mail-strip-quoted-names (buffer-substring this-line this-line-end)))) | |
903 ) | |
904 (erase-buffer) | |
41497
608d7b92d289
Simplify previous change.
Richard M. Stallman <rms@gnu.org>
parents:
41492
diff
changeset
|
905 (insert " " simple-address-list "\n") |
15345 | 906 (subst-char-in-region (point-min) (point-max) 10 ? t);; newline --> blank |
907 (subst-char-in-region (point-min) (point-max) ?, ? t);; comma --> blank | |
908 (subst-char-in-region (point-min) (point-max) 9 ? t);; tab --> blank | |
909 | |
910 (goto-char (point-min)) | |
911 ;; tidyness in case hook is not robust when it looks at this | |
912 (while (re-search-forward "[ \t]+" header-end t) (replace-match " ")) | |
913 | |
914 (goto-char (point-min)) | |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
915 (let (recipient-address-list) |
15451
89c1e7fe879a
(smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents:
15372
diff
changeset
|
916 (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
|
917 (backward-char 1) |
15451
89c1e7fe879a
(smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents:
15372
diff
changeset
|
918 (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
|
919 recipient-address-list)) |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
920 ) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
921 (setq smtpmail-recipient-address-list recipient-address-list)) |
15345 | 922 |
923 ) | |
24663
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
924 ) |
15345 | 925 ) |
926 ) | |
927 | |
928 | |
929 (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
|
930 "Delete [Resent-]BCC: and their continuation lines from the header area. |
15345 | 931 There may be multiple BCC: lines, and each may have arbitrarily |
932 many continuation lines." | |
933 (let ((case-fold-search t)) | |
24455 | 934 (save-excursion |
935 (goto-char (point-min)) | |
936 ;; iterate over all BCC: lines | |
937 (while (re-search-forward "^\\(RESENT-\\)?BCC:" header-end t) | |
938 (delete-region (match-beginning 0) | |
939 (progn (forward-line 1) (point))) | |
940 ;; get rid of any continuation lines | |
941 (while (and (looking-at "^[ \t].*\n") (< (point) header-end)) | |
942 (replace-match "")))))) | |
15345 | 943 |
944 | |
945 (provide 'smtpmail) | |
946 | |
17517 | 947 ;;; smtpmail.el ends here |