annotate lisp/mail/smtpmail.el @ 45106:53adea9b47b7

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