annotate lisp/mail/uce.el @ 21440:4718a738947a

(help-with-tutorial-alist): This variable deleted. (help-with-tutorial): Get a tutorial file name by get-language-info instead of help-with-tutorial-alist.
author Kenichi Handa <handa@m17n.org>
date Thu, 09 Apr 1998 05:39:11 +0000
parents 54413501e4a9
children 2abd8542d6dd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; uce.el --- facilitate reply to unsolicited commercial email
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1996 Free Software Foundation, Inc.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: stanislav shalunov <shalunov@math.wisc.edu>
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Created: 10 Dec 1996
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Version: 1.0
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; Keywords: uce, unsolicited commercial email
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; This program is free software; you can redistribute it and/or
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; modify it under the terms of the GNU General Public License as
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; published by the Free Software Foundation; either version 2, or (at
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; your option) any later version.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; This program is distributed in the hope that it will be useful, but
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; without any warranty; without even the implied warranty of
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; merchantability or fitness for a particular purpose. See the GNU
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; General Public License for more details.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; Code in this file provides semi-automatic means of replying to
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; UCE's you might get. It works currently only with Rmail. If you
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; would like to make it work with other mail readers, Rmail-specific
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; section is marked below. If you want to play with code, would you
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; please grab the newest version from
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; http://math.wisc.edu/~shalunov/uce.el and let me know, if you would
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; like, about your changes so I can incorporate them. I'd appreciate
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; it.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; Function uce-reply-to-uce, if called when current message in RMAIL
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; buffer is a UCE, will setup *mail* buffer in the following way: it
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; scans full headers of message for 1) normal return address of
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; sender (From, Reply-To lines); and puts these addresses into To:
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; header, it also puts abuse@offenders.host address there 2) mailhub
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; that first saw this message; and puts address of its postmaster
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; into To: header 3) finally, it looks at Message-Id and adds
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; posmaster of that host to the list of addresses.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; Then, we add "Errors-To: nobody@localhost" header, so that if some
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; of these addresses are not actually correct, we will never see
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; bounced mail. Also, mail-self-blind and mail-archive-file-name
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;; take no effect: the ideology is that we don't want to save junk or
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; replies to junk.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; Then we put template into buffer (customizable message that
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; explains what has happened), customizable signature, and the
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; original message with full headers and envelope for postmasters.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; Then buffer is left for editing.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; The reason that function uce-reply-to-uce is Rmail dependant is
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; that we want full headers of the original message, nothing
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; stripped. If we use normal means of inserting of the original
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; message into *mail* buffer headers like Received: (not really
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;; headers, but envelope lines) will be stripped while they bear
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; valuable for us and postmasters information. I do wish that there
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; would be some way to write this function in some portable way, but
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; I am not aware of any.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;;; Change log:
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; Dec 10, 1996 -- posted draft version to gnu.sources.emacs
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; Dec 11, 1996 -- fixed some typos, and Francesco Potorti`
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; <F.Potorti@cnuce.cnr.it> pointed out that my use of defvar was
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; weird, suggested fix, and added let form.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; Dec 17, 1996 -- made scanning for host names little bit more clever
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;; (obviously bogus stuff like localhost is now ignored).
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;;; Setup:
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; put in your ~./emacs the following line:
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; (autoload 'uce-reply-to-uce "uce" "Reply to UCEs" t nil)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;; store this file (uce.el) somewhere in load-path and byte-compile it.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;;; Variables:
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; uce-message-text is template that will be inserted into buffer. It
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 ;; has reasonable default. If you want to write some scarier one,
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ;; please do so and send it to me. Please keep it polite.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 ;; uce-signature behaves just like mail-signature. If nil, nothing is
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;; inserted, if t, file ~/.signature is used, if a string, its
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ;; contents are inserted into buffer.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;; uce-uce-separator is line that separates your message from the UCE
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 ;; that you enclose.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; uce-subject-line will be used as subject of outgoing message. If
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ;; nil, left blank.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;;; Code:
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (require 'sendmail)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (require 'rmail)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
107 (defgroup uce nil
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
108 "Facilitate reply to unsolicited commercial email."
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
109 :prefix "uce-"
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
110 :group 'mail)
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
111
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
112 (defcustom uce-setup-hook nil
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 "Hook to run after UCE rant message is composed.
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
114 This hook is run after mail-setup-hook, which is run as well."
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
115 :type 'hook
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
116 :group 'uce)
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
118 (defcustom uce-message-text
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 "Recently, I have received an Unsolicited Commercial E-mail from you.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 I do not like UCE's and I would like to inform you that sending
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 unsolicited messages to someone while he or she may have to pay for
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 reading your message may be illegal. Anyway, it is highly annoying
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 and not welcome by anyone. It is rude, after all.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 If you think that this is a good way to advertise your products or
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 services you are mistaken. Spamming will only make people hate you, not
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 buy from you.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 If you have any list of people you send unsolicited commercial emails to,
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 REMOVE me from such list immediately. I suggest that you make this list
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 just empty.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 Note to the postmaster(s): I append the text of UCE in question to
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 this message, I would like to hear from you about action(s) taken.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 This message has been sent to postmasters at the host that is
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 mentioned as original sender's host and to the postmaster whose host
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 was used as mail relay for this message. If message was sent not by
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 your user, could you please compare time when this message was sent
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (use time in Received: field of the envelope rather than Date: field)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 with your sendmail logs and see what host was using your sendmail at
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 this moment of time.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 Thank you."
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 "This is the text that uce-reply-to-uce command will put in reply buffer.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 Some of spamming programs in use will be set up to read all incoming
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 to spam address email, and will remove people who put the word `remove'
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 on beginning of some line from the spamming list. So, when you set it
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 up, it might be a good idea to actually use this feature.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
151 Value nil means insert no text by default, lets you type it in."
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
152 :type 'string
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
153 :group 'uce)
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
155 (defcustom uce-uce-separator
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 "----- original unsolicited commercial email follows -----"
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 "Line that will begin quoting of the UCE.
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
158 Value nil means use no separator."
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
159 :type '(choice (const nil) string)
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
160 :group 'uce)
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
162 (defcustom uce-signature mail-signature
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 "Text to put as your signature after the note to UCE sender.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 Value nil means none, t means insert ~/.signature file (if it happens
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 to exist), if this variable is a string this string will be inserted
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
166 as your signature."
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
167 :type '(choice (const nil) (const t) string)
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
168 :group 'uce)
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
170 (defcustom uce-default-headers
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 "Errors-To: nobody@localhost\nPrecedence: bulk\n"
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 "Additional headers to use when responding to a UCE with \\[uce-reply-to-uce].
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
173 These are mostly meant for headers that prevent delivery errors reporting."
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
174 :type 'string
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
175 :group 'uce)
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
177 (defcustom uce-subject-line
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 "Spam alert: unsolicited commercial e-mail"
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
179 "Subject of the message that will be sent in response to a UCE."
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
180 :type 'string
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 17450
diff changeset
181 :group 'uce)
17450
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (defun uce-reply-to-uce (&optional ignored)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 "Send reply to UCE in Rmail.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 UCE stands for unsolicited commercial email. Function will set up reply
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 buffer with default To: to the sender, his postmaster, his abuse@
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 address, and postmaster of the mail relay used."
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (interactive "P")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (let ((to (mail-strip-quoted-names (mail-fetch-field "from" t)))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (reply-to (mail-fetch-field "reply-to"))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 temp)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 ;; Initial setting of the list of recipients of our message; that's
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 ;; what they are pretending to be (and in many cases, really are).
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (if to
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (setq to (format "%s" (mail-strip-quoted-names to)))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (setq to ""))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (if reply-to
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (setq to (format "%s, %s" to (mail-strip-quoted-names reply-to))))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (let (first-at-sign end-of-hostname sender-host)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (setq first-at-sign (string-match "@" to)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 end-of-hostname (string-match "[ ,>]" to first-at-sign)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 sender-host (substring to first-at-sign end-of-hostname))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (if (string-match "\\." sender-host)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (setq to (format "%s, postmaster%s, abuse%s"
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 to sender-host sender-host))))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (setq mail-send-actions nil)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (setq mail-reply-buffer nil)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 ;; Begin of Rmail dependant section.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (or (get-buffer "RMAIL")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (error "No buffer RMAIL, cannot find UCE"))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 (switch-to-buffer "RMAIL")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (save-excursion
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (save-restriction
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (widen)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (rmail-maybe-set-message-counters)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (copy-region-as-kill (rmail-msgbeg rmail-current-message)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (rmail-msgend rmail-current-message))))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (switch-to-buffer "*mail*")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (erase-buffer)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (setq temp (point))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (yank)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (goto-char temp)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (forward-line 2)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (while (looking-at "Summary-Line:\\|Mail-From:")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (forward-line 1))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 (delete-region temp (point))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 ;; Now find the mail hub that first accepted this message.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (while (or (looking-at "Received:")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (looking-at " ")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (looking-at "\t"))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 (forward-line 1))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (while (or (looking-at " ")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (looking-at "\t"))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (forward-line -1))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 ;; Is this always good? It's the only thing I saw when I checked
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 ;; a few messages.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (search-forward ": from ")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (setq temp (point))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (search-forward " ")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (forward-char -1)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 ;; And add its postmaster to the list of addresses.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (if (string-match "\\." (buffer-substring temp (point)))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (setq to (format "%s, postmaster@%s"
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 to (buffer-substring temp (point)))))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 ;; Also look at the message-id, it helps *very* often.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (search-forward "\nMessage-Id: ")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (search-forward "@")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (setq temp (point))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (search-forward ">")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (forward-char -1)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (if (string-match "\\." (buffer-substring temp (point)))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (setq to (format "%s, postmaster@%s"
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 to (buffer-substring temp (point)))))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (search-forward "\n*** EOOH ***\n")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (forward-line -1)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (setq temp (point))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (search-forward "\n\n" nil t)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (delete-region temp (point))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 ;; End of Rmail dependent section.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (auto-save-mode auto-save-default)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (mail-mode)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (goto-char (point-min))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (insert "To: ")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (save-excursion
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (if to
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (let ((fill-prefix "\t")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (address-start (point)))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 (insert to "\n")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (fill-region-as-paragraph address-start (point)))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (newline))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (insert "Subject: " uce-subject-line "\n")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (if uce-default-headers
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (insert uce-default-headers))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (if mail-default-headers
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (insert mail-default-headers))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (if mail-default-reply-to
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (insert "Reply-to: " mail-default-reply-to "\n"))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (insert mail-header-separator "\n")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 ;; Insert all our text. Then go back to the place where we started.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (if to (setq to (point)))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 ;; Text of ranting.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (if uce-message-text
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 (insert uce-message-text))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 ;; Signature.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (cond ((eq uce-signature t)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (if (file-exists-p "~/.signature")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (progn
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (insert "\n\n-- \n")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (insert-file "~/.signature")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 ;; Function insert-file leaves point where it was,
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 ;; while we want to place signature in the ``middle''
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 ;; of the message.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (exchange-point-and-mark))))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (uce-signature
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (insert "\n\n-- \n" uce-signature)))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 ;; And text of the original message.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (if uce-uce-separator
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (insert "\n\n" uce-uce-separator "\n"))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 ;; If message doesn't end with a newline, insert it.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (goto-char (point-max))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 (or (bolp) (newline)))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 ;; And go back to the beginning of text.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (if to (goto-char to))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (or to (set-buffer-modified-p nil))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 ;; Run hooks before we leave buffer for editing. Reasonable usage
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 ;; might be to set up special key bindings, replace standart
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 ;; functions in mail-mode, etc.
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 (run-hooks 'mail-setup-hook 'uce-setup-hook)))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 (defun uce-insert-ranting (&optional ignored)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 "Insert text of the usual reply to UCE into current buffer."
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (interactive "P")
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (insert uce-message-text))
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 (provide 'uce)
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316
bbf1df3de440 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 ;;; uce.el ends here