Mercurial > emacs
annotate lisp/mail/smtpmail.el @ 95351:d797842f5ca1
(update-elclist): Work around non-portability of "\" in various
implementations of echo.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Wed, 28 May 2008 03:18:34 +0000 |
parents | e1d2da11b5ac |
children | a9fc7556436a |
rev | line source |
---|---|
17517 | 1 ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail |
15345 | 2 |
68648
067115a6e738
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
68250
diff
changeset
|
3 ;; Copyright (C) 1995, 1996, 2001, 2002, 2003, 2004, 2005, |
79712 | 4 ;; 2006, 2007, 2008 Free Software Foundation, Inc. |
15345 | 5 |
6 ;; 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
|
7 ;; 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
|
8 ;; 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
|
9 ;; ESMTP support: Simon Leinen <simon@switch.ch> |
37800
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
10 ;; 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
|
11 ;; 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
|
12 ;; AUTH=LOGIN support: Stephen Cranefield <scranefield@infoscience.otago.ac.nz> |
15345 | 13 ;; Keywords: mail |
14 | |
15 ;; This file is part of GNU Emacs. | |
16 | |
94674
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
17 ;; GNU Emacs is free software: you can redistribute it and/or modify |
15345 | 18 ;; it under the terms of the GNU General Public License as published by |
94674
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
19 ;; the Free Software Foundation, either version 3 of the License, or |
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
20 ;; (at your option) any later version. |
15345 | 21 |
22 ;; GNU Emacs is distributed in the hope that it will be useful, | |
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 ;; GNU General Public License for more details. | |
26 | |
27 ;; You should have received a copy of the GNU General Public License | |
94674
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
28 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
15345 | 29 |
30 ;;; Commentary: | |
31 | |
32 ;; Send Mail to smtp host from smtpmail temp buffer. | |
33 | |
23142
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
34 ;; Please add these lines in your .emacs(_emacs) or use customize. |
15345 | 35 ;; |
23142
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
36 ;;(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
|
37 ;;(setq message-send-mail-function 'smtpmail-send-it) ; if you use message/Gnus |
15345 | 38 ;;(setq smtpmail-default-smtp-server "YOUR SMTP HOST") |
39 ;;(setq smtpmail-local-domain "YOUR DOMAIN NAME") | |
26028
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
40 ;;(setq smtpmail-sendto-domain "YOUR DOMAIN NAME") |
23142
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
41 ;;(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
|
42 ;;(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
|
43 ;; '(("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
|
44 ;;(setq smtpmail-starttls-credentials |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
45 ;; '(("YOUR SMTP HOST" 25 "~/.my_smtp_tls.key" "~/.my_smtp_tls.cert"))) |
54763
63ed691cfee6
Add comment, based on report by kdc@rcn.com (Kevin D. Clark).
Simon Josefsson <jas@extundo.com>
parents:
54350
diff
changeset
|
46 ;; Where the 25 equals the value of `smtpmail-smtp-service', it can be an |
63ed691cfee6
Add comment, based on report by kdc@rcn.com (Kevin D. Clark).
Simon Josefsson <jas@extundo.com>
parents:
54350
diff
changeset
|
47 ;; integer or a string, just as long as they match (eq). |
15345 | 48 |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
49 ;; To queue mail, set smtpmail-queue-mail to t and use |
18094 | 50 ;; smtpmail-send-queued-mail to send. |
51 | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
52 ;; 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
|
53 ;; 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
|
54 ;; 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
|
55 ;; 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
|
56 ;; support below. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
57 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
58 ;; 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
|
59 ;; 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
|
60 ;; 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
|
61 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
62 ;; 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
|
63 ;; STARTTLS. Requires external program |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
64 ;; 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
|
65 ;; See http://www.ietf.org/rfc/rfc2246.txt, http://www.ietf.org/rfc/rfc2487.txt |
18094 | 66 |
15345 | 67 ;;; Code: |
68 | |
69 (require 'sendmail) | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
70 (autoload 'starttls-open-stream "starttls") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
71 (autoload 'starttls-negotiate "starttls") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
72 (autoload 'mail-strip-quoted-names "mail-utils") |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
73 (autoload 'message-make-date "message") |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
74 (autoload 'message-make-message-id "message") |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
75 (autoload 'rfc2104-hash "rfc2104") |
44868
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
76 (autoload 'netrc-parse "netrc") |
45179
6ff2c20da16e
(netrc-machine, netrc-get): Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
44883
diff
changeset
|
77 (autoload 'netrc-machine "netrc") |
6ff2c20da16e
(netrc-machine, netrc-get): Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
44883
diff
changeset
|
78 (autoload 'netrc-get "netrc") |
91843
499730b7bd8e
2008-02-14 Justus Piater <Justus-bulk@Piater.name> (tiny change)
Bastien Guerry <bzg@altern.org>
parents:
91820
diff
changeset
|
79 (autoload 'password-read "password-cache") |
15345 | 80 |
94880 | 81 (eval-and-compile |
82 (autoload 'auth-source-user-or-password "auth-source")) | |
83 | |
15345 | 84 ;;; |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
85 (defgroup smtpmail nil |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
86 "SMTP protocol for sending mail." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
87 :group 'mail) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
88 |
15345 | 89 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
90 (defcustom smtpmail-default-smtp-server nil |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
91 "Specify default SMTP server. |
47396
d7fa9253971f
(smtpmail-default-smtp-server): Doc fix.
Simon Josefsson <jas@extundo.com>
parents:
47225
diff
changeset
|
92 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
|
93 :type '(choice (const nil) string) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
94 :group 'smtpmail) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
95 |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
96 (defcustom smtpmail-smtp-server |
15451
89c1e7fe879a
(smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents:
15372
diff
changeset
|
97 (or (getenv "SMTPSERVER") smtpmail-default-smtp-server) |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
98 "The name of the host running SMTP server." |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
99 :type '(choice (const nil) string) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
100 :group 'smtpmail) |
15345 | 101 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
102 (defcustom smtpmail-smtp-service 25 |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
103 "SMTP service port number. |
75739
d6f3ca7298f7
(smtpmail-smtp-service, smtpmail-queue-index-file): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
104 The default value would be \"smtp\" or 25." |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
105 :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
|
106 :group 'smtpmail) |
15345 | 107 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
108 (defcustom smtpmail-local-domain nil |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
109 "Local domain name without a host name. |
75739
d6f3ca7298f7
(smtpmail-smtp-service, smtpmail-queue-index-file): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
110 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
|
111 don't define this value." |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
112 :type '(choice (const nil) string) |
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
113 :group 'smtpmail) |
15345 | 114 |
26028
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
115 (defcustom smtpmail-sendto-domain nil |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
116 "Local domain name without a host name. |
26028
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
117 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
|
118 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
|
119 \(Some configurations of sendmail require this.) |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
120 |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
121 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
|
122 Sending failed; SMTP protocol error |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
123 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
|
124 buffer includes an exchange like: |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
125 RCPT TO: <someone> |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
126 501 <someone>: recipient address must contain a domain |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
127 " |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
128 :type '(choice (const nil) string) |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
129 :group 'smtpmail) |
a0126ac842dc
(smtpmail-via-smtp): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
24871
diff
changeset
|
130 |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
131 (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
|
132 "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
|
133 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
|
134 be verbose as well." |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
135 :type 'boolean |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
136 :group 'smtpmail) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
137 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
138 (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
|
139 "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
|
140 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
|
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 |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
144 (defcustom smtpmail-code-conv-from nil |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
145 "Coding system for encoding outgoing mail. |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
146 Used for the value of `sendmail-coding-system' when |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
147 `select-message-coding-system' is called. " |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
148 :type 'coding-system |
17436
2a9fdbfcb993
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16907
diff
changeset
|
149 :group 'smtpmail) |
15345 | 150 |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
151 (defcustom smtpmail-queue-mail nil |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
152 "Non-nil means mail is queued; otherwise it is sent immediately. |
18094 | 153 If queued, it is stored in the directory `smtpmail-queue-dir' |
154 and sent with `smtpmail-send-queued-mail'." | |
155 :type 'boolean | |
156 :group 'smtpmail) | |
157 | |
158 (defcustom smtpmail-queue-dir "~/Mail/queued-mail/" | |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
159 "Directory where `smtpmail.el' stores queued mail." |
18094 | 160 :type 'directory |
161 :group 'smtpmail) | |
162 | |
44868
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
163 (defcustom smtpmail-auth-credentials "~/.authinfo" |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
164 "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
|
165 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
|
166 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
|
167 `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
|
168 `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
|
169 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
|
170 looks like `user@realm'." |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
171 :type '(choice file |
865b7fdda4bb
(smtpmail-auth-credentials): Support netrc files as well.
Richard M. Stallman <rms@gnu.org>
parents:
44864
diff
changeset
|
172 (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
|
173 (integer :tag "Port") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
174 (string :tag "Username") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
175 (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
|
176 (string :tag "Password"))))) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59159
diff
changeset
|
177 :version "22.1" |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
178 :group 'smtpmail) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
179 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
180 (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
|
181 "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
|
182 This is a list of four-element list with `servername' (a string), |
72671
b1e05ba6e2b1
2006-09-06 Simon Josefsson <jas@extundo.com>
Simon Josefsson <jas@extundo.com>
parents:
68648
diff
changeset
|
183 `port' (an integer), `key' (a filename) and `certificate' (a |
b1e05ba6e2b1
2006-09-06 Simon Josefsson <jas@extundo.com>
Simon Josefsson <jas@extundo.com>
parents:
68648
diff
changeset
|
184 filename). |
b1e05ba6e2b1
2006-09-06 Simon Josefsson <jas@extundo.com>
Simon Josefsson <jas@extundo.com>
parents:
68648
diff
changeset
|
185 If you do not have a certificate/key pair, leave the `key' and |
b1e05ba6e2b1
2006-09-06 Simon Josefsson <jas@extundo.com>
Simon Josefsson <jas@extundo.com>
parents:
68648
diff
changeset
|
186 `certificate' fields as `nil'. A key/certificate pair is only |
b1e05ba6e2b1
2006-09-06 Simon Josefsson <jas@extundo.com>
Simon Josefsson <jas@extundo.com>
parents:
68648
diff
changeset
|
187 needed if you want to use X.509 client authenticated |
b1e05ba6e2b1
2006-09-06 Simon Josefsson <jas@extundo.com>
Simon Josefsson <jas@extundo.com>
parents:
68648
diff
changeset
|
188 connections." |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
189 :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
|
190 (integer :tag "Port") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
191 (file :tag "Key") |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
192 (file :tag "Certificate"))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
193 :version "21.1" |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
194 :group 'smtpmail) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
195 |
37598
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
196 (defcustom smtpmail-warn-about-unknown-extensions nil |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
197 "If set, print warnings about unknown SMTP extensions. |
37598
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
198 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
|
199 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
|
200 :type 'boolean |
37600
20c37aac51cd
(smtpmail-warn-about-unknown-extensions): Add :version.
Gerd Moellmann <gerd@gnu.org>
parents:
37598
diff
changeset
|
201 :version "21.1" |
37598
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
202 :group 'smtpmail) |
595c23d107f8
(smtpmail-warn-about-unknown-extensions): New
Gerd Moellmann <gerd@gnu.org>
parents:
26028
diff
changeset
|
203 |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
204 (defcustom smtpmail-queue-index-file "index" |
75739
d6f3ca7298f7
(smtpmail-smtp-service, smtpmail-queue-index-file): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
205 "File name of queued mail index. |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
206 This is relative to `smtpmail-queue-dir'." |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
207 :type 'string |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
208 :group 'smtpmail) |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
209 |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
210 ;; End of customizable variables. |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
211 |
18094 | 212 |
23444
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
213 (defvar smtpmail-address-buffer) |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
214 (defvar smtpmail-recipient-address-list) |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
215 |
44864
c18dd95f6962
(smtpmail-queue-counter): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
42225
diff
changeset
|
216 (defvar smtpmail-queue-counter 0) |
c18dd95f6962
(smtpmail-queue-counter): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
42225
diff
changeset
|
217 |
23444
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
218 ;; Buffer-local variable. |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
219 (defvar smtpmail-read-point) |
a632871d7cfa
(smtpmail-send-data-1): Use encode-coding-string.
Richard M. Stallman <rms@gnu.org>
parents:
23181
diff
changeset
|
220 |
64416
3b19cfc14a51
(smtpmail-auth-supported): Prefer PLAIN over LOGIN.
Simon Josefsson <jas@extundo.com>
parents:
64414
diff
changeset
|
221 (defconst smtpmail-auth-supported '(cram-md5 plain login) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
222 "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
|
223 |
45252
ee1b06064fbb
(smtpmail-mail-address): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45204
diff
changeset
|
224 (defvar smtpmail-mail-address nil |
52321
e4b050573b12
(smtpmail-mail-address): Doc change.
Glenn Morris <rgm@gnu.org>
parents:
51895
diff
changeset
|
225 "Value to use for envelope-from address for mail from ambient buffer.") |
45252
ee1b06064fbb
(smtpmail-mail-address): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
45204
diff
changeset
|
226 |
23142
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
227 ;;;###autoload |
15345 | 228 (defun smtpmail-send-it () |
229 (let ((errbuf (if mail-interactive | |
230 (generate-new-buffer " smtpmail errors") | |
231 0)) | |
232 (tembuf (generate-new-buffer " smtpmail temp")) | |
233 (case-fold-search nil) | |
234 delimline | |
24773 | 235 (mailbuf (current-buffer)) |
52347 | 236 ;; Examine this variable now, so that |
237 ;; local binding in the mail buffer will take effect. | |
52321
e4b050573b12
(smtpmail-mail-address): Doc change.
Glenn Morris <rgm@gnu.org>
parents:
51895
diff
changeset
|
238 (smtpmail-mail-address |
e4b050573b12
(smtpmail-mail-address): Doc change.
Glenn Morris <rgm@gnu.org>
parents:
51895
diff
changeset
|
239 (or (and mail-specify-envelope-from (mail-envelope-from)) |
e4b050573b12
(smtpmail-mail-address): Doc change.
Glenn Morris <rgm@gnu.org>
parents:
51895
diff
changeset
|
240 user-mail-address)) |
24773 | 241 (smtpmail-code-conv-from |
242 (if enable-multibyte-characters | |
243 (let ((sendmail-coding-system smtpmail-code-conv-from)) | |
244 (select-message-coding-system))))) | |
15345 | 245 (unwind-protect |
246 (save-excursion | |
247 (set-buffer tembuf) | |
248 (erase-buffer) | |
74158
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
249 ;; Use the same buffer-file-coding-system as in the mail |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
250 ;; buffer, otherwise any write-region invocations (e.g., in |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
251 ;; mail-do-fcc below) will annoy with asking for a suitable |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
252 ;; encoding. |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
253 (set-buffer-file-coding-system smtpmail-code-conv-from nil t) |
15345 | 254 (insert-buffer-substring mailbuf) |
255 (goto-char (point-max)) | |
256 ;; require one newline at the end. | |
257 (or (= (preceding-char) ?\n) | |
258 (insert ?\n)) | |
259 ;; 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
|
260 (mail-sendmail-undelimit-header) |
15345 | 261 (setq delimline (point-marker)) |
15451
89c1e7fe879a
(smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents:
15372
diff
changeset
|
262 ;; (sendmail-synch-aliases) |
15345 | 263 (if mail-aliases |
264 (expand-mail-aliases (point-min) delimline)) | |
265 (goto-char (point-min)) | |
266 ;; ignore any blank lines in the header | |
267 (while (and (re-search-forward "\n\n\n*" delimline t) | |
268 (< (point) delimline)) | |
269 (replace-match "\n")) | |
270 (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
|
271 ;; 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
|
272 ;; 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
|
273 ;; is done correctly in smtpmail-deduce-address-list. |
15345 | 274 ;; Don't send out a blank subject line |
275 (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
|
276 (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
|
277 (replace-match "") |
dfb671ba22f8
(smtpmail-send-it): Deleted all code related to Resent-To: processing.
Richard M. Stallman <rms@gnu.org>
parents:
20058
diff
changeset
|
278 ;; 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
|
279 (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
|
280 (= (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
|
281 (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
|
282 ;; 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
|
283 ;; 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
|
284 (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
|
285 (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
|
286 (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
|
287 (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
|
288 (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
|
289 (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
|
290 (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
|
291 (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 ;; 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
|
294 ;; 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
|
295 (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
|
296 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 (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
|
298 ;; 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
|
299 (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
|
300 (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
|
301 (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
|
302 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
|
303 (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
|
304 (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
|
305 (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
|
306 ((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
|
307 (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
|
308 (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
|
309 (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
|
310 (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
|
311 (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
|
312 ;; 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
|
313 ;; 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
|
314 ;; 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
|
315 (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
|
316 (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
|
317 ;; ... 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
|
318 ;; 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
|
319 (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
|
320 (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
|
321 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)" |
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 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
|
323 (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
|
324 (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
|
325 (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
|
326 ((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
|
327 (insert "From: " login "\n"))))) |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
328 ;; 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
|
329 (goto-char (point-min)) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
330 (unless (re-search-forward "^Message-Id:" delimline t) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
331 (insert "Message-Id: " (message-make-message-id) "\n")) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
332 ;; 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
|
333 (goto-char (point-min)) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
334 (unless (re-search-forward "^Date:" delimline t) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
335 (insert "Date: " (message-make-date) "\n")) |
74158
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
336 ;; Possibly add a MIME header for the current coding system |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
337 (let (charset) |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
338 (goto-char (point-min)) |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
339 (and (eq mail-send-nonascii 'mime) |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
340 (not (re-search-forward "^MIME-version:" delimline t)) |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
341 (progn (skip-chars-forward "\0-\177") |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
342 (/= (point) (point-max))) |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
343 smtpmail-code-conv-from |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
344 (setq charset |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
345 (coding-system-get smtpmail-code-conv-from |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
346 'mime-charset)) |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
347 (goto-char delimline) |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
348 (insert "MIME-version: 1.0\n" |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
349 "Content-type: text/plain; charset=" |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
350 (symbol-name charset) |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
351 "\nContent-Transfer-Encoding: 8bit\n"))) |
15345 | 352 ;; Insert an extra newline if we need it to work around |
353 ;; Sun's bug that swallows newlines. | |
354 (goto-char (1+ delimline)) | |
355 (if (eval mail-mailer-swallows-blank-line) | |
356 (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
|
357 ;; 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
|
358 (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
|
359 (if (re-search-forward "^FCC:" delimline t) |
74158
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
360 ;; Force mail-do-fcc to use the encoding of the mail |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
361 ;; buffer to encode outgoing messages on FCC files. |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
362 (let ((coding-system-for-write smtpmail-code-conv-from)) |
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
363 (mail-do-fcc delimline))) |
15345 | 364 (if mail-interactive |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
365 (with-current-buffer errbuf |
15345 | 366 (erase-buffer)))) |
367 ;; | |
368 ;; | |
369 ;; | |
370 (setq smtpmail-address-buffer (generate-new-buffer "*smtp-mail*")) | |
371 (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
|
372 (smtpmail-deduce-address-list tembuf (point-min) delimline)) |
15345 | 373 (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
|
374 |
15345 | 375 (smtpmail-do-bcc delimline) |
18094 | 376 ; Send or queue |
377 (if (not smtpmail-queue-mail) | |
378 (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
|
379 (if (not (smtpmail-via-smtp |
18094 | 380 smtpmail-recipient-address-list tembuf)) |
381 (error "Sending failed; SMTP protocol error")) | |
382 (error "Sending failed; no recipients")) | |
47436
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
383 (let* ((file-data |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
384 (expand-file-name |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
385 (format "%s_%i" |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
386 (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
|
387 (setq smtpmail-queue-counter |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
388 (1+ smtpmail-queue-counter))) |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
389 smtpmail-queue-dir)) |
dc7ce8219431
(smtpmail-send-it): Don't use : in filenames
Simon Josefsson <jas@extundo.com>
parents:
47396
diff
changeset
|
390 (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
|
391 (file-elisp (concat file-data ".el")) |
18094 | 392 (buffer-data (create-file-buffer file-data)) |
393 (buffer-elisp (create-file-buffer file-elisp)) | |
394 (buffer-scratch "*queue-mail*")) | |
51895
2f47cd5fd50d
(smtpmail-send-it): Create smtpmail-queue-dir if it doesn't exist.
Juanma Barranquero <lekktu@gmail.com>
parents:
50973
diff
changeset
|
395 (unless (file-exists-p smtpmail-queue-dir) |
2f47cd5fd50d
(smtpmail-send-it): Create smtpmail-queue-dir if it doesn't exist.
Juanma Barranquero <lekktu@gmail.com>
parents:
50973
diff
changeset
|
396 (make-directory smtpmail-queue-dir t)) |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
397 (with-current-buffer buffer-data |
18094 | 398 (erase-buffer) |
74158
07973a5d9639
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
Eli Zaretskii <eliz@gnu.org>
parents:
73418
diff
changeset
|
399 (set-buffer-file-coding-system smtpmail-code-conv-from nil t) |
68250
3db62d37041f
(smtpmail-send-it): Use insert-buffer-substring.
Jesper Harder <harder@ifa.au.dk>
parents:
68117
diff
changeset
|
400 (insert-buffer-substring tembuf) |
18094 | 401 (write-file file-data) |
402 (set-buffer buffer-elisp) | |
403 (erase-buffer) | |
404 (insert (concat | |
405 "(setq smtpmail-recipient-address-list '" | |
406 (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
|
407 ")\n")) |
18094 | 408 (write-file file-elisp) |
409 (set-buffer (generate-new-buffer buffer-scratch)) | |
410 (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
|
411 (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
|
412 (point-max) |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
413 (expand-file-name smtpmail-queue-index-file |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
414 smtpmail-queue-dir))) |
18094 | 415 (kill-buffer buffer-scratch) |
416 (kill-buffer buffer-data) | |
417 (kill-buffer buffer-elisp)))) | |
15345 | 418 (kill-buffer tembuf) |
419 (if (bufferp errbuf) | |
420 (kill-buffer errbuf))))) | |
421 | |
48419
03ac1463ec5e
(smtpmail-send-queued-mail): Add autoload cookie.
Juanma Barranquero <lekktu@gmail.com>
parents:
47837
diff
changeset
|
422 ;;;###autoload |
18094 | 423 (defun smtpmail-send-queued-mail () |
424 "Send mail that was queued as a result of setting `smtpmail-queue-mail'." | |
425 (interactive) | |
42225
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
426 (with-temp-buffer |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
427 ;;; 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
|
428 ;;; mail, send it, etc... |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
429 (let ((file-msg "") |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
430 (qfile (expand-file-name smtpmail-queue-index-file |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
431 smtpmail-queue-dir))) |
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
432 (insert-file-contents qfile) |
62621
078b075e8984
(smtpmail-open-stream): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
62402
diff
changeset
|
433 (goto-char (point-min)) |
18094 | 434 (while (not (eobp)) |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
435 (setq file-msg (buffer-substring (point) (line-end-position))) |
18094 | 436 (load file-msg) |
41921
de4a90cd0a5f
(smtpmail-send-queued-mail): Insert the enqueued messages literally.
Eli Zaretskii <eliz@gnu.org>
parents:
41716
diff
changeset
|
437 ;; 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
|
438 ;; 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
|
439 ;; encoding wrongly. |
42225
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
440 (with-temp-buffer |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
441 (let ((coding-system-for-read 'no-conversion)) |
8ef1ae58dc29
(smtpmail-send-queued-mail): Use
Eli Zaretskii <eliz@gnu.org>
parents:
41921
diff
changeset
|
442 (insert-file-contents file-msg)) |
52347 | 443 (let ((smtpmail-mail-address |
444 (or (and mail-specify-envelope-from (mail-envelope-from)) | |
445 user-mail-address))) | |
446 (if (not (null smtpmail-recipient-address-list)) | |
447 (if (not (smtpmail-via-smtp smtpmail-recipient-address-list | |
448 (current-buffer))) | |
449 (error "Sending failed; SMTP protocol error")) | |
450 (error "Sending failed; no recipients")))) | |
18094 | 451 (delete-file file-msg) |
452 (delete-file (concat file-msg ".el")) | |
50931
0ef58c420b53
(smtpmail-send-queued-mail): Use point-at-bol instead of forward-line.
Juanma Barranquero <lekktu@gmail.com>
parents:
50912
diff
changeset
|
453 (delete-region (point-at-bol) (point-at-bol 2))) |
92129
1f3cc233058d
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
91844
diff
changeset
|
454 (write-region (point-min) (point-max) qfile)))) |
15345 | 455 |
456 ;(defun smtpmail-via-smtp (host,port,sender,destination,smtpmail-text-buffer) | |
457 | |
458 (defun smtpmail-fqdn () | |
459 (if smtpmail-local-domain | |
460 (concat (system-name) "." smtpmail-local-domain) | |
461 (system-name))) | |
462 | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
463 (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
|
464 (nth 0 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
465 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
466 (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
|
467 (nth 1 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
468 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
469 (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
|
470 (nth 2 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
471 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
472 (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
|
473 (nth 2 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
474 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
475 (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
|
476 (nth 3 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
477 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
478 (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
|
479 (nth 3 cred)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
480 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
481 (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
|
482 (catch 'done |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
483 (let ((l cred) el) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
484 (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
|
485 (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
|
486 (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
|
487 (throw 'done el)))))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
488 |
37800
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
489 (defun smtpmail-maybe-append-domain (recipient) |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
490 (if (or (not smtpmail-sendto-domain) |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
491 (string-match "@" recipient)) |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
492 recipient |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
493 (concat recipient "@" smtpmail-sendto-domain))) |
9cddd888d25f
(maybe-append-domain): Renamed to
Gerd Moellmann <gerd@gnu.org>
parents:
37600
diff
changeset
|
494 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
495 (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
|
496 (let ((result nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
497 (dolist (el2 list2) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
498 (when (memq el2 list1) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
499 (push el2 result))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
500 (nreverse result))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
501 |
62621
078b075e8984
(smtpmail-open-stream): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
62402
diff
changeset
|
502 (defvar starttls-extra-args) |
078b075e8984
(smtpmail-open-stream): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
62402
diff
changeset
|
503 (defvar starttls-extra-arguments) |
078b075e8984
(smtpmail-open-stream): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
62402
diff
changeset
|
504 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
505 (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
|
506 (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
|
507 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
|
508 (if (null (and cred (condition-case () |
62621
078b075e8984
(smtpmail-open-stream): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
62402
diff
changeset
|
509 (with-no-warnings |
50973
7f434a265bfa
(smtpmail-open-stream): Don't hard code
Simon Josefsson <jas@extundo.com>
parents:
50931
diff
changeset
|
510 (require 'starttls) |
57435
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
511 (call-process (if starttls-use-gnutls |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
512 starttls-gnutls-program |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
513 starttls-program))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
514 (error nil)))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
515 ;; The normal case. |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
516 (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
|
517 (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
|
518 (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
|
519 (starttls-extra-args |
57435
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
520 (append |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
521 starttls-extra-args |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
522 (when (and (stringp cred-key) (stringp cred-cert) |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
523 (file-regular-p |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
524 (setq cred-key (expand-file-name cred-key))) |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
525 (file-regular-p |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
526 (setq cred-cert (expand-file-name cred-cert)))) |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
527 (list "--key-file" cred-key "--cert-file" cred-cert)))) |
55786
a4b0f825c65a
(smtpmail-open-stream): Bind
Simon Josefsson <jas@extundo.com>
parents:
54763
diff
changeset
|
528 (starttls-extra-arguments |
57435
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
529 (append |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
530 starttls-extra-arguments |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
531 (when (and (stringp cred-key) (stringp cred-cert) |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
532 (file-regular-p |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
533 (setq cred-key (expand-file-name cred-key))) |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
534 (file-regular-p |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
535 (setq cred-cert (expand-file-name cred-cert)))) |
2b938e7f92a5
(smtpmail-open-stream): Look for
Simon Josefsson <jas@extundo.com>
parents:
55786
diff
changeset
|
536 (list "--x509keyfile" cred-key "--x509certfile" cred-cert))))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
537 (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
|
538 |
91844
ee383bc4d019
(password-cache-add): Declare as function.
Glenn Morris <rgm@gnu.org>
parents:
91843
diff
changeset
|
539 ;; password-read autoloads password-cache. |
ee383bc4d019
(password-cache-add): Declare as function.
Glenn Morris <rgm@gnu.org>
parents:
91843
diff
changeset
|
540 (declare-function password-cache-add "password-cache" (key password)) |
ee383bc4d019
(password-cache-add): Declare as function.
Glenn Morris <rgm@gnu.org>
parents:
91843
diff
changeset
|
541 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
542 (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
|
543 (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
|
544 (mech (car (smtpmail-intersection smtpmail-auth-supported mechs))) |
94880 | 545 (auth-user (auth-source-user-or-password |
546 "login" host (or port "smtp"))) | |
547 (auth-pass (auth-source-user-or-password | |
548 "password" host (or port "smtp"))) | |
549 (cred (if (and auth-user auth-pass) ; try user-auth-* before netrc-* | |
550 (list host port auth-user auth-pass) | |
551 ;; else, if auth-source didn't return them... | |
552 (if (stringp smtpmail-auth-credentials) | |
553 (let* ((netrc (netrc-parse smtpmail-auth-credentials)) | |
554 (port-name (format "%s" (or port "smtp"))) | |
555 (hostentry (netrc-machine netrc host port-name | |
556 port-name))) | |
557 (when hostentry | |
558 (list host port | |
559 (netrc-get hostentry "login") | |
560 (netrc-get hostentry "password")))) | |
561 ;; else, try smtpmail-find-credentials since | |
562 ;; smtpmail-auth-credentials is not a string | |
563 (smtpmail-find-credentials | |
564 smtpmail-auth-credentials host port)))) | |
91820
f084b6fae1f0
* mail/smtpmail.el: Use password-cache.
Bastien Guerry <bzg@altern.org>
parents:
79712
diff
changeset
|
565 (prompt (when cred (format "SMTP password for %s:%s: " |
f084b6fae1f0
* mail/smtpmail.el: Use password-cache.
Bastien Guerry <bzg@altern.org>
parents:
79712
diff
changeset
|
566 (smtpmail-cred-server cred) |
f084b6fae1f0
* mail/smtpmail.el: Use password-cache.
Bastien Guerry <bzg@altern.org>
parents:
79712
diff
changeset
|
567 (smtpmail-cred-port cred)))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
568 (passwd (when cred |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
569 (or (smtpmail-cred-passwd cred) |
91820
f084b6fae1f0
* mail/smtpmail.el: Use password-cache.
Bastien Guerry <bzg@altern.org>
parents:
79712
diff
changeset
|
570 (password-read prompt prompt)))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
571 ret) |
53807
61abf9ce6838
(smtpmail-try-auth-methods): Pass port-name as defaultport to `netrc-machine'.
Sam Steingold <sds@gnu.org>
parents:
53641
diff
changeset
|
572 (when (and cred mech) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
573 (cond |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
574 ((eq mech 'cram-md5) |
59159 | 575 (smtpmail-send-command process (upcase (format "AUTH %s" mech))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
576 (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
|
577 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
578 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
579 (throw 'done nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
580 (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
|
581 (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
|
582 (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
|
583 (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
|
584 (response (concat (smtpmail-cred-user cred) " " hash)) |
73418 | 585 ;; Osamu Yamane <yamane@green.ocn.ne.jp>: |
586 ;; SMTP auth fails because the SMTP server identifies | |
587 ;; only the first part of the string (delimited by | |
588 ;; new line characters) as a response from the | |
589 ;; client, and the rest as distinct commands. | |
590 | |
591 ;; In my case, the response string is 80 characters | |
592 ;; long. Without the no-line-break option for | |
593 ;; base64-encode-sting, only the first 76 characters | |
594 ;; are taken as a response to the server, and the | |
595 ;; authentication fails. | |
73148
6887b498642b
* mail/smtpmail.el (smtpmail-try-auth-methods): Do not break long
Chong Yidong <cyd@stupidchicken.com>
parents:
72671
diff
changeset
|
596 (encoded (base64-encode-string response t))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
597 (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
|
598 (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
|
599 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
600 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
601 (throw 'done nil))))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
602 ((eq mech 'login) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
603 (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
|
604 (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
|
605 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
606 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
607 (throw 'done nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
608 (smtpmail-send-command |
73215
32b78c90379a
2006-10-02 MIYOSHI Masanori <miyoshi@meadowy.org> (tiny change)
Simon Josefsson <jas@extundo.com>
parents:
73148
diff
changeset
|
609 process (base64-encode-string (smtpmail-cred-user cred) t)) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
610 (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
|
611 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
612 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
613 (throw 'done nil)) |
73148
6887b498642b
* mail/smtpmail.el (smtpmail-try-auth-methods): Do not break long
Chong Yidong <cyd@stupidchicken.com>
parents:
72671
diff
changeset
|
614 (smtpmail-send-command process (base64-encode-string passwd t)) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
615 (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
|
616 (not (integerp (car ret))) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
617 (>= (car ret) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
618 (throw 'done nil))) |
64414
84d21f8fafbb
(smtpmail-auth-supported): Added the 'plain auth method
Simon Josefsson <jas@extundo.com>
parents:
64085
diff
changeset
|
619 ((eq mech 'plain) |
68117
340b01243a62
Add comment describing AUTH PLAIN fix.
Simon Josefsson <jas@extundo.com>
parents:
67873
diff
changeset
|
620 ;; We used to send an empty initial request, and wait for an |
340b01243a62
Add comment describing AUTH PLAIN fix.
Simon Josefsson <jas@extundo.com>
parents:
67873
diff
changeset
|
621 ;; empty response, and then send the password, but this |
340b01243a62
Add comment describing AUTH PLAIN fix.
Simon Josefsson <jas@extundo.com>
parents:
67873
diff
changeset
|
622 ;; violate a SHOULD in RFC 2222 paragraph 5.1. Note that this |
340b01243a62
Add comment describing AUTH PLAIN fix.
Simon Josefsson <jas@extundo.com>
parents:
67873
diff
changeset
|
623 ;; is not sent if the server did not advertise AUTH PLAIN in |
340b01243a62
Add comment describing AUTH PLAIN fix.
Simon Josefsson <jas@extundo.com>
parents:
67873
diff
changeset
|
624 ;; the EHLO response. See RFC 2554 for more info. |
67873
51ca2759364a
Fix AUTH PLAIN authentication.
Simon Josefsson <jas@extundo.com>
parents:
67424
diff
changeset
|
625 (smtpmail-send-command process |
51ca2759364a
Fix AUTH PLAIN authentication.
Simon Josefsson <jas@extundo.com>
parents:
67424
diff
changeset
|
626 (concat "AUTH PLAIN " |
51ca2759364a
Fix AUTH PLAIN authentication.
Simon Josefsson <jas@extundo.com>
parents:
67424
diff
changeset
|
627 (base64-encode-string |
64414
84d21f8fafbb
(smtpmail-auth-supported): Added the 'plain auth method
Simon Josefsson <jas@extundo.com>
parents:
64085
diff
changeset
|
628 (concat "\0" |
84d21f8fafbb
(smtpmail-auth-supported): Added the 'plain auth method
Simon Josefsson <jas@extundo.com>
parents:
64085
diff
changeset
|
629 (smtpmail-cred-user cred) |
84d21f8fafbb
(smtpmail-auth-supported): Added the 'plain auth method
Simon Josefsson <jas@extundo.com>
parents:
64085
diff
changeset
|
630 "\0" |
73148
6887b498642b
* mail/smtpmail.el (smtpmail-try-auth-methods): Do not break long
Chong Yidong <cyd@stupidchicken.com>
parents:
72671
diff
changeset
|
631 passwd) t))) |
64414
84d21f8fafbb
(smtpmail-auth-supported): Added the 'plain auth method
Simon Josefsson <jas@extundo.com>
parents:
64085
diff
changeset
|
632 (if (or (null (car (setq ret (smtpmail-read-response process)))) |
84d21f8fafbb
(smtpmail-auth-supported): Added the 'plain auth method
Simon Josefsson <jas@extundo.com>
parents:
64085
diff
changeset
|
633 (not (integerp (car ret))) |
84d21f8fafbb
(smtpmail-auth-supported): Added the 'plain auth method
Simon Josefsson <jas@extundo.com>
parents:
64085
diff
changeset
|
634 (not (equal (car ret) 235))) |
84d21f8fafbb
(smtpmail-auth-supported): Added the 'plain auth method
Simon Josefsson <jas@extundo.com>
parents:
64085
diff
changeset
|
635 (throw 'done nil))) |
84d21f8fafbb
(smtpmail-auth-supported): Added the 'plain auth method
Simon Josefsson <jas@extundo.com>
parents:
64085
diff
changeset
|
636 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
637 (t |
64414
84d21f8fafbb
(smtpmail-auth-supported): Added the 'plain auth method
Simon Josefsson <jas@extundo.com>
parents:
64085
diff
changeset
|
638 (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
|
639 ;; Remember the password. |
91820
f084b6fae1f0
* mail/smtpmail.el: Use password-cache.
Bastien Guerry <bzg@altern.org>
parents:
79712
diff
changeset
|
640 (when (null (smtpmail-cred-passwd cred)) |
f084b6fae1f0
* mail/smtpmail.el: Use password-cache.
Bastien Guerry <bzg@altern.org>
parents:
79712
diff
changeset
|
641 (password-cache-add prompt passwd))))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
642 |
15345 | 643 (defun smtpmail-via-smtp (recipient smtpmail-text-buffer) |
644 (let ((process nil) | |
23142
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
645 (host (or smtpmail-smtp-server |
98c430cac424
(smtpmail-send-it): Add autoload cookie.
Karl Heuer <kwzh@gnu.org>
parents:
22037
diff
changeset
|
646 (error "`smtpmail-smtp-server' not defined"))) |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
647 (port smtpmail-smtp-service) |
52347 | 648 ;; smtpmail-mail-address should be set to the appropriate |
649 ;; buffer-local value by the caller, but in case not: | |
650 (envelope-from (or smtpmail-mail-address | |
651 (and mail-specify-envelope-from | |
652 (mail-envelope-from)) | |
653 user-mail-address)) | |
15345 | 654 response-code |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
655 greeting |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
656 process-buffer |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
657 (supported-extensions '())) |
15345 | 658 (unwind-protect |
659 (catch 'done | |
660 ;; get or create the trace buffer | |
661 (setq process-buffer | |
662 (get-buffer-create (format "*trace of SMTP session to %s*" host))) | |
663 | |
664 ;; clear the trace buffer of old output | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
665 (with-current-buffer process-buffer |
67424
02c3cfe8d00b
(smtpmail-via-smtp): Disable undo in SMTP buffer.
Kim F. Storm <storm@cua.dk>
parents:
67347
diff
changeset
|
666 (setq buffer-undo-list t) |
15345 | 667 (erase-buffer)) |
668 | |
669 ;; 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
|
670 (setq process (smtpmail-open-stream process-buffer host port)) |
15345 | 671 (and (null process) (throw 'done nil)) |
672 | |
673 ;; set the send-filter | |
674 (set-process-filter process 'smtpmail-process-filter) | |
675 | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
676 (with-current-buffer process-buffer |
22037
cb95bfcd442a
(smtpmail-via-smtp): Speciy process coding system.
Richard M. Stallman <rms@gnu.org>
parents:
21862
diff
changeset
|
677 (set-buffer-process-coding-system 'raw-text-unix 'raw-text-unix) |
15345 | 678 (make-local-variable 'smtpmail-read-point) |
679 (setq smtpmail-read-point (point-min)) | |
680 | |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
681 |
15345 | 682 (if (or (null (car (setq greeting (smtpmail-read-response process)))) |
683 (not (integerp (car greeting))) | |
684 (>= (car greeting) 400)) | |
685 (throw 'done nil) | |
686 ) | |
687 | |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
688 (let ((do-ehlo t) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
689 (do-starttls t)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
690 (while do-ehlo |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
691 ;; EHLO |
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 "EHLO %s" (smtpmail-fqdn))) |
15345 | 693 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
694 (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
|
695 (smtpmail-read-response process)))) |
15345 | 696 (not (integerp (car response-code))) |
697 (>= (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
|
698 (progn |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
699 ;; HELO |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
700 (smtpmail-send-command |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
701 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
|
702 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
703 (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
|
704 (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
|
705 (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
|
706 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
707 (throw 'done nil))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
708 (dolist (line (cdr (cdr response-code))) |
76942
3c8672cf3035
(smtpmail-via-smtp): Use ascii-case-table when downcasing.
Chong Yidong <cyd@stupidchicken.com>
parents:
76908
diff
changeset
|
709 (let ((name |
3c8672cf3035
(smtpmail-via-smtp): Use ascii-case-table when downcasing.
Chong Yidong <cyd@stupidchicken.com>
parents:
76908
diff
changeset
|
710 (with-case-table ascii-case-table |
3c8672cf3035
(smtpmail-via-smtp): Use ascii-case-table when downcasing.
Chong Yidong <cyd@stupidchicken.com>
parents:
76908
diff
changeset
|
711 (mapcar (lambda (s) (intern (downcase s))) |
3c8672cf3035
(smtpmail-via-smtp): Use ascii-case-table when downcasing.
Chong Yidong <cyd@stupidchicken.com>
parents:
76908
diff
changeset
|
712 (split-string (substring line 4) "[ ]"))))) |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
713 (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
|
714 (setq name (car name))) |
76908
714d51db2c25
(smtpmail-via-smtp): Fix indentation.
Eli Zaretskii <eliz@gnu.org>
parents:
76902
diff
changeset
|
715 (and name |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
716 (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
|
717 '(verb xvrb 8bitmime onex xone |
76908
714d51db2c25
(smtpmail-via-smtp): Fix indentation.
Eli Zaretskii <eliz@gnu.org>
parents:
76902
diff
changeset
|
718 expn size dsn etrn |
714d51db2c25
(smtpmail-via-smtp): Fix indentation.
Eli Zaretskii <eliz@gnu.org>
parents:
76902
diff
changeset
|
719 enhancedstatuscodes |
714d51db2c25
(smtpmail-via-smtp): Fix indentation.
Eli Zaretskii <eliz@gnu.org>
parents:
76902
diff
changeset
|
720 help xusr |
714d51db2c25
(smtpmail-via-smtp): Fix indentation.
Eli Zaretskii <eliz@gnu.org>
parents:
76902
diff
changeset
|
721 auth=login auth starttls)) |
714d51db2c25
(smtpmail-via-smtp): Fix indentation.
Eli Zaretskii <eliz@gnu.org>
parents:
76902
diff
changeset
|
722 (setq supported-extensions |
714d51db2c25
(smtpmail-via-smtp): Fix indentation.
Eli Zaretskii <eliz@gnu.org>
parents:
76902
diff
changeset
|
723 (cons name supported-extensions))) |
714d51db2c25
(smtpmail-via-smtp): Fix indentation.
Eli Zaretskii <eliz@gnu.org>
parents:
76902
diff
changeset
|
724 (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
|
725 (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
|
726 |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
727 (if (and do-starttls |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
728 (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
|
729 (member 'starttls supported-extensions) |
47672
666b84b52b82
(smtpmail-via-smtp): Only negotiate starttls on
Simon Josefsson <jas@extundo.com>
parents:
47436
diff
changeset
|
730 (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
|
731 (progn |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
732 (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
|
733 (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
|
734 (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
|
735 (>= (car response-code) 400)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
736 (throw 'done nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
737 (starttls-negotiate process) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
738 (setq do-starttls nil)) |
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
739 (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
|
740 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
741 (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
|
742 |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
743 (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
|
744 (member 'xone supported-extensions)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
745 (progn |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
746 (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
|
747 (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
|
748 (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
|
749 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
750 (throw 'done nil)))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
751 |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
752 (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
|
753 (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
|
754 (member 'xvrb supported-extensions))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
755 (progn |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
756 (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
|
757 (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
|
758 (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
|
759 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
760 (throw 'done nil)))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
761 |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
762 (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
|
763 (progn |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
764 (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
|
765 (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
|
766 (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
|
767 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
768 (throw 'done nil)))) |
15345 | 769 |
52642
79320037f627
(smtpmail-via-smtp): Don't insert a space
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
770 ;; MAIL FROM:<sender> |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
771 (let ((size-part |
41221
b6fd3363a398
(smtpmail-cred-server, smtpmail-cred-port, smtpmail-cred-key)
Richard M. Stallman <rms@gnu.org>
parents:
40033
diff
changeset
|
772 (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
|
773 (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
|
774 (format " SIZE=%d" |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
775 (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
|
776 ;; size estimate: |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
777 (+ (- (point-max) (point-min)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
778 ;; Add one byte for each change-of-line |
53641
e33121530d13
Jesper Harder <harder@ifa.au.dk>
Glenn Morris <rgm@gnu.org>
parents:
53619
diff
changeset
|
779 ;; because of CR-LF representation: |
e33121530d13
Jesper Harder <harder@ifa.au.dk>
Glenn Morris <rgm@gnu.org>
parents:
53619
diff
changeset
|
780 (count-lines (point-min) (point-max))))) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
781 "")) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
782 (body-part |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
783 (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
|
784 ;; FIXME: |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
785 ;; 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
|
786 ;; 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
|
787 ;; 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
|
788 ;; 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
|
789 ;; 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
|
790 ;; 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
|
791 ;; 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
|
792 ;; 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
|
793 ;; 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
|
794 ;; 8BITMIME. |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
795 (if nil |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
796 " BODY=8BITMIME" |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
797 "") |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
798 ""))) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
799 ; (smtpmail-send-command process (format "MAIL FROM:%s@%s" (user-login-name) (smtpmail-fqdn))) |
52642
79320037f627
(smtpmail-via-smtp): Don't insert a space
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
800 (smtpmail-send-command process (format "MAIL FROM:<%s>%s%s" |
52347 | 801 envelope-from |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
802 size-part |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
803 body-part)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48846
diff
changeset
|
804 |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
805 (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
|
806 (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
|
807 (>= (car response-code) 400)) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
808 (throw 'done nil) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
809 )) |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
810 |
52642
79320037f627
(smtpmail-via-smtp): Don't insert a space
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
811 ;; RCPT TO:<recipient> |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
812 (let ((n 0)) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
813 (while (not (null (nth n recipient))) |
52642
79320037f627
(smtpmail-via-smtp): Don't insert a space
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
814 (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
|
815 (setq n (1+ n)) |
15345 | 816 |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
817 (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
|
818 (if (or (null (car response-code)) |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
819 (not (integerp (car response-code))) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
820 (>= (car response-code) 400)) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
821 (throw 'done nil) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
822 ) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
823 )) |
44883
7d867b33aa2d
(smtpmail-try-auth-methods): host is not in the authinfo/netrc => cred=nil.
Sam Steingold <sds@gnu.org>
parents:
44868
diff
changeset
|
824 |
15345 | 825 ;; DATA |
826 (smtpmail-send-command process "DATA") | |
827 | |
828 (if (or (null (car (setq response-code (smtpmail-read-response process)))) | |
829 (not (integerp (car response-code))) | |
830 (>= (car response-code) 400)) | |
831 (throw 'done nil) | |
832 ) | |
833 | |
834 ;; Mail contents | |
835 (smtpmail-send-data process smtpmail-text-buffer) | |
836 | |
837 ;;DATA end "." | |
838 (smtpmail-send-command process ".") | |
839 | |
840 (if (or (null (car (setq response-code (smtpmail-read-response process)))) | |
841 (not (integerp (car response-code))) | |
842 (>= (car response-code) 400)) | |
843 (throw 'done nil) | |
844 ) | |
845 | |
846 ;;QUIT | |
847 ; (smtpmail-send-command process "QUIT") | |
848 ; (and (null (car (smtpmail-read-response process))) | |
849 ; (throw 'done nil)) | |
850 t )) | |
851 (if process | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
852 (with-current-buffer (process-buffer process) |
15345 | 853 (smtpmail-send-command process "QUIT") |
854 (smtpmail-read-response process) | |
855 | |
856 ; (if (or (null (car (setq response-code (smtpmail-read-response process)))) | |
857 ; (not (integerp (car response-code))) | |
858 ; (>= (car response-code) 400)) | |
859 ; (throw 'done nil) | |
860 ; ) | |
47117
c6c0e4cc9d0a
(smtpmail-via-smtp): Delete process buffer
Simon Josefsson <jas@extundo.com>
parents:
45252
diff
changeset
|
861 (delete-process process) |
c6c0e4cc9d0a
(smtpmail-via-smtp): Delete process buffer
Simon Josefsson <jas@extundo.com>
parents:
45252
diff
changeset
|
862 (unless smtpmail-debug-info |
c6c0e4cc9d0a
(smtpmail-via-smtp): Delete process buffer
Simon Josefsson <jas@extundo.com>
parents:
45252
diff
changeset
|
863 (kill-buffer process-buffer))))))) |
15345 | 864 |
865 | |
866 (defun smtpmail-process-filter (process output) | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
867 (with-current-buffer (process-buffer process) |
15345 | 868 (goto-char (point-max)) |
869 (insert output))) | |
870 | |
871 (defun smtpmail-read-response (process) | |
872 (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
|
873 (response-strings nil) |
15345 | 874 (response-continue t) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
875 (return-value '(nil ())) |
15345 | 876 match-end) |
54350
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
877 (catch 'done |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
878 (while response-continue |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
879 (goto-char smtpmail-read-point) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
880 (while (not (search-forward "\r\n" nil t)) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
881 (unless (memq (process-status process) '(open run)) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
882 (throw 'done nil)) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
883 (accept-process-output process) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
884 (goto-char smtpmail-read-point)) |
15345 | 885 |
54350
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
886 (setq match-end (point)) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
887 (setq response-strings |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
888 (cons (buffer-substring smtpmail-read-point (- match-end 2)) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
889 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
|
890 |
54350
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
891 (goto-char smtpmail-read-point) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
892 (if (looking-at "[0-9]+ ") |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
893 (let ((begin (match-beginning 0)) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
894 (end (match-end 0))) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
895 (if smtpmail-debug-info |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
896 (message "%s" (car response-strings))) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
897 |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
898 (setq smtpmail-read-point match-end) |
15345 | 899 |
54350
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
900 ;; ignore lines that start with "0" |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
901 (if (looking-at "0[0-9]+ ") |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
902 nil |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
903 (setq response-continue nil) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
904 (setq return-value |
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
905 (cons (string-to-number |
54350
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
906 (buffer-substring begin end)) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
907 (nreverse response-strings))))) |
15345 | 908 |
54350
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
909 (if (looking-at "[0-9]+-") |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
910 (progn (if smtpmail-debug-info |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
911 (message "%s" (car response-strings))) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
912 (setq smtpmail-read-point match-end) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
913 (setq response-continue t)) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
914 (progn |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
915 (setq smtpmail-read-point match-end) |
18092
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
916 (setq response-continue nil) |
8428d56cd207
(smtpmail-via-smtp): Recognize XVRB as a synonym for
Richard M. Stallman <rms@gnu.org>
parents:
17517
diff
changeset
|
917 (setq return-value |
54350
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
918 (cons nil (nreverse response-strings))))))) |
e7ea873f6f2e
(smtpmail-read-response): Abort if process has
Simon Josefsson <jas@extundo.com>
parents:
53919
diff
changeset
|
919 (setq smtpmail-read-point match-end)) |
15345 | 920 return-value)) |
921 | |
922 | |
923 (defun smtpmail-send-command (process command) | |
924 (goto-char (point-max)) | |
925 (if (= (aref command 0) ?P) | |
926 (insert "PASS <omitted>\r\n") | |
927 (insert command "\r\n")) | |
928 (setq smtpmail-read-point (point)) | |
929 (process-send-string process command) | |
930 (process-send-string process "\r\n")) | |
931 | |
932 (defun smtpmail-send-data-1 (process data) | |
933 (goto-char (point-max)) | |
934 | |
24773 | 935 (if (and (multibyte-string-p data) |
936 smtpmail-code-conv-from) | |
937 (setq data (string-as-multibyte | |
938 (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
|
939 |
15345 | 940 (if smtpmail-debug-info |
941 (insert data "\r\n")) | |
942 | |
943 (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
|
944 ;; 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
|
945 (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
|
946 (process-send-string process ".")) |
15345 | 947 (process-send-string process data) |
948 (process-send-string process "\r\n") | |
949 ) | |
950 | |
951 (defun smtpmail-send-data (process buffer) | |
53619
f69d407a9996
Jesper Harder <harder@ifa.au.dk>
Glenn Morris <rgm@gnu.org>
parents:
52642
diff
changeset
|
952 (let ((data-continue t) sending-data) |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
953 (with-current-buffer buffer |
15345 | 954 (goto-char (point-min))) |
955 (while data-continue | |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
956 (with-current-buffer buffer |
53619
f69d407a9996
Jesper Harder <harder@ifa.au.dk>
Glenn Morris <rgm@gnu.org>
parents:
52642
diff
changeset
|
957 (setq sending-data (buffer-substring (point-at-bol) (point-at-eol))) |
f69d407a9996
Jesper Harder <harder@ifa.au.dk>
Glenn Morris <rgm@gnu.org>
parents:
52642
diff
changeset
|
958 (end-of-line 2) |
f69d407a9996
Jesper Harder <harder@ifa.au.dk>
Glenn Morris <rgm@gnu.org>
parents:
52642
diff
changeset
|
959 (setq data-continue (not (eobp)))) |
f69d407a9996
Jesper Harder <harder@ifa.au.dk>
Glenn Morris <rgm@gnu.org>
parents:
52642
diff
changeset
|
960 (smtpmail-send-data-1 process sending-data)))) |
15345 | 961 |
962 (defun smtpmail-deduce-address-list (smtpmail-text-buffer header-start header-end) | |
963 "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
|
964 (unwind-protect |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
965 (with-current-buffer smtpmail-address-buffer |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
966 (erase-buffer) |
24663
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
967 (let |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
968 ((case-fold-search t) |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
969 (simple-address-list "") |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
970 this-line |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
971 this-line-end |
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
972 addr-regexp) |
15345 | 973 (insert-buffer-substring smtpmail-text-buffer header-start header-end) |
974 (goto-char (point-min)) | |
15648
2feeabc94834
(smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents:
15595
diff
changeset
|
975 ;; 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
|
976 (save-excursion |
41716
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
977 (setq addr-regexp |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
978 (if (re-search-forward "^Resent-\\(to\\|cc\\|bcc\\):" |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
979 header-end t) |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
980 "^Resent-\\(to\\|cc\\|bcc\\):" |
e467d0e8f243
Use with-current-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41497
diff
changeset
|
981 "^\\(To:\\|Cc:\\|Bcc:\\)"))) |
15648
2feeabc94834
(smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents:
15595
diff
changeset
|
982 |
2feeabc94834
(smtpmail-deduce-address-list): Handle RESENT-* fields.
Karl Heuer <kwzh@gnu.org>
parents:
15595
diff
changeset
|
983 (while (re-search-forward addr-regexp header-end t) |
15345 | 984 (replace-match "") |
985 (setq this-line (match-beginning 0)) | |
986 (forward-line 1) | |
987 ;; get any continuation lines | |
988 (while (and (looking-at "^[ \t]+") (< (point) header-end)) | |
989 (forward-line 1)) | |
990 (setq this-line-end (point-marker)) | |
991 (setq simple-address-list | |
992 (concat simple-address-list " " | |
993 (mail-strip-quoted-names (buffer-substring this-line this-line-end)))) | |
994 ) | |
995 (erase-buffer) | |
41497
608d7b92d289
Simplify previous change.
Richard M. Stallman <rms@gnu.org>
parents:
41492
diff
changeset
|
996 (insert " " simple-address-list "\n") |
15345 | 997 (subst-char-in-region (point-min) (point-max) 10 ? t);; newline --> blank |
998 (subst-char-in-region (point-min) (point-max) ?, ? t);; comma --> blank | |
999 (subst-char-in-region (point-min) (point-max) 9 ? t);; tab --> blank | |
1000 | |
1001 (goto-char (point-min)) | |
1002 ;; tidyness in case hook is not robust when it looks at this | |
1003 (while (re-search-forward "[ \t]+" header-end t) (replace-match " ")) | |
1004 | |
1005 (goto-char (point-min)) | |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
1006 (let (recipient-address-list) |
15451
89c1e7fe879a
(smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents:
15372
diff
changeset
|
1007 (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
|
1008 (backward-char 1) |
15451
89c1e7fe879a
(smtpmail-smtp-service): Use port 25 as default.
Richard M. Stallman <rms@gnu.org>
parents:
15372
diff
changeset
|
1009 (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
|
1010 recipient-address-list)) |
15346
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
1011 ) |
4cd6ff2384dc
(smtpmail-send-it): Fix error messages.
Richard M. Stallman <rms@gnu.org>
parents:
15345
diff
changeset
|
1012 (setq smtpmail-recipient-address-list recipient-address-list)) |
15345 | 1013 |
1014 ) | |
24663
39edc9c7b235
(smtpmail-deduce-address-list): Bind variables
Andrew Innes <andrewi@gnu.org>
parents:
24455
diff
changeset
|
1015 ) |
15345 | 1016 ) |
1017 ) | |
1018 | |
1019 | |
1020 (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
|
1021 "Delete [Resent-]BCC: and their continuation lines from the header area. |
15345 | 1022 There may be multiple BCC: lines, and each may have arbitrarily |
1023 many continuation lines." | |
1024 (let ((case-fold-search t)) | |
24455 | 1025 (save-excursion |
1026 (goto-char (point-min)) | |
1027 ;; iterate over all BCC: lines | |
1028 (while (re-search-forward "^\\(RESENT-\\)?BCC:" header-end t) | |
1029 (delete-region (match-beginning 0) | |
1030 (progn (forward-line 1) (point))) | |
1031 ;; get rid of any continuation lines | |
1032 (while (and (looking-at "^[ \t].*\n") (< (point) header-end)) | |
1033 (replace-match "")))))) | |
15345 | 1034 |
1035 | |
1036 (provide 'smtpmail) | |
1037 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92129
diff
changeset
|
1038 ;; arch-tag: a76992df-6d71-43b7-9e72-4bacc6c05466 |
17517 | 1039 ;;; smtpmail.el ends here |