comparison lisp/mail/uce.el @ 49598:0d8b17d428b5

Trailing whitepace deleted.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 04 Feb 2003 13:24:35 +0000
parents 3a4e24e20c8d
children 695cf19ef79e d7ddb3e565de
comparison
equal deleted inserted replaced
49597:e88404e8f2cf 49598:0d8b17d428b5
115 ;;; Code: 115 ;;; Code:
116 116
117 (require 'sendmail) 117 (require 'sendmail)
118 ;; Those sections of code which are dependent upon 118 ;; Those sections of code which are dependent upon
119 ;; RMAIL are only evaluated if we have received a message with RMAIL... 119 ;; RMAIL are only evaluated if we have received a message with RMAIL...
120 ;;(require 'rmail) 120 ;;(require 'rmail)
121 121
122 (defgroup uce nil 122 (defgroup uce nil
123 "Facilitate reply to unsolicited commercial email." 123 "Facilitate reply to unsolicited commercial email."
124 :prefix "uce-" 124 :prefix "uce-"
125 :group 'mail) 125 :group 'mail)
135 "Hook to run after UCE rant message is composed. 135 "Hook to run after UCE rant message is composed.
136 This hook is run after `mail-setup-hook', which is run as well." 136 This hook is run after `mail-setup-hook', which is run as well."
137 :type 'hook 137 :type 'hook
138 :group 'uce) 138 :group 'uce)
139 139
140 (defcustom uce-message-text 140 (defcustom uce-message-text
141 "Recently, I have received an Unsolicited Commercial E-mail from you. 141 "Recently, I have received an Unsolicited Commercial E-mail from you.
142 I do not like UCE's and I would like to inform you that sending 142 I do not like UCE's and I would like to inform you that sending
143 unsolicited messages to someone while he or she may have to pay for 143 unsolicited messages to someone while he or she may have to pay for
144 reading your message may be illegal. Anyway, it is highly annoying 144 reading your message may be illegal. Anyway, it is highly annoying
145 and not welcome by anyone. It is rude, after all. 145 and not welcome by anyone. It is rude, after all.
146 146
147 If you think that this is a good way to advertise your products or 147 If you think that this is a good way to advertise your products or
148 services you are mistaken. Spamming will only make people hate you, not 148 services you are mistaken. Spamming will only make people hate you, not
149 buy from you. 149 buy from you.
150 150
151 If you have any list of people you send unsolicited commercial emails to, 151 If you have any list of people you send unsolicited commercial emails to,
152 REMOVE me from such list immediately. I suggest that you make this list 152 REMOVE me from such list immediately. I suggest that you make this list
153 just empty. 153 just empty.
154 154
155 ---------------------------------------------------- 155 ----------------------------------------------------
156 156
157 If you are not an administrator of any site and still have received 157 If you are not an administrator of any site and still have received
190 Value nil means use no separator." 190 Value nil means use no separator."
191 :type '(choice (const nil) string) 191 :type '(choice (const nil) string)
192 :group 'uce) 192 :group 'uce)
193 193
194 (defcustom uce-signature mail-signature 194 (defcustom uce-signature mail-signature
195 "Text to put as your signature after the note to UCE sender. 195 "Text to put as your signature after the note to UCE sender.
196 Value nil means none, t means insert `~/.signature' file (if it happens 196 Value nil means none, t means insert `~/.signature' file (if it happens
197 to exist), if this variable is a string this string will be inserted 197 to exist), if this variable is a string this string will be inserted
198 as your signature." 198 as your signature."
199 :type '(choice (const nil) (const t) string) 199 :type '(choice (const nil) (const t) string)
200 :group 'uce) 200 :group 'uce)
219 address, and postmaster of the mail relay used." 219 address, and postmaster of the mail relay used."
220 (interactive) 220 (interactive)
221 (let ((message-buffer 221 (let ((message-buffer
222 (cond ((eq uce-mail-reader 'gnus) gnus-original-article-buffer) 222 (cond ((eq uce-mail-reader 'gnus) gnus-original-article-buffer)
223 ((eq uce-mail-reader 'rmail) "RMAIL") 223 ((eq uce-mail-reader 'rmail) "RMAIL")
224 (t (error 224 (t (error
225 "Variable uce-mail-reader set to unrecognized value")))) 225 "Variable uce-mail-reader set to unrecognized value"))))
226 (full-header-p (and (eq uce-mail-reader 'rmail) 226 (full-header-p (and (eq uce-mail-reader 'rmail)
227 (not (rmail-msg-is-pruned))))) 227 (not (rmail-msg-is-pruned)))))
228 (or (get-buffer message-buffer) 228 (or (get-buffer message-buffer)
229 (error (concat "No buffer " message-buffer ", cannot find UCE"))) 229 (error (concat "No buffer " message-buffer ", cannot find UCE")))
244 (let (first-at-sign end-of-hostname sender-host) 244 (let (first-at-sign end-of-hostname sender-host)
245 (setq first-at-sign (string-match "@" to) 245 (setq first-at-sign (string-match "@" to)
246 end-of-hostname (string-match "[ ,>]" to first-at-sign) 246 end-of-hostname (string-match "[ ,>]" to first-at-sign)
247 sender-host (substring to first-at-sign end-of-hostname)) 247 sender-host (substring to first-at-sign end-of-hostname))
248 (if (string-match "\\." sender-host) 248 (if (string-match "\\." sender-host)
249 (setq to (format "%s, postmaster%s, abuse%s" 249 (setq to (format "%s, postmaster%s, abuse%s"
250 to sender-host sender-host)))) 250 to sender-host sender-host))))
251 (setq mail-send-actions nil) 251 (setq mail-send-actions nil)
252 (setq mail-reply-buffer nil) 252 (setq mail-reply-buffer nil)
253 (cond ((eq uce-mail-reader 'gnus) 253 (cond ((eq uce-mail-reader 'gnus)
254 (copy-region-as-kill (point-min) (point-max))) 254 (copy-region-as-kill (point-min) (point-max)))
256 (save-excursion 256 (save-excursion
257 (save-restriction 257 (save-restriction
258 (rmail-toggle-header 1) 258 (rmail-toggle-header 1)
259 (widen) 259 (widen)
260 (rmail-maybe-set-message-counters) 260 (rmail-maybe-set-message-counters)
261 (copy-region-as-kill (rmail-msgbeg rmail-current-message) 261 (copy-region-as-kill (rmail-msgbeg rmail-current-message)
262 (rmail-msgend rmail-current-message)))))) 262 (rmail-msgend rmail-current-message))))))
263 ;; Restore the pruned header state we found. 263 ;; Restore the pruned header state we found.
264 (if full-header-p 264 (if full-header-p
265 (rmail-toggle-header 0)) 265 (rmail-toggle-header 0))
266 (switch-to-buffer "*mail*") 266 (switch-to-buffer "*mail*")
284 (beginning-of-line)) 284 (beginning-of-line))
285 ((eq uce-mail-reader 'rmail) 285 ((eq uce-mail-reader 'rmail)
286 (beginning-of-buffer) 286 (beginning-of-buffer)
287 (search-forward "*** EOOH ***\n") 287 (search-forward "*** EOOH ***\n")
288 (beginning-of-line) 288 (beginning-of-line)
289 (forward-line -1))) 289 (forward-line -1)))
290 (re-search-backward "^Received:") 290 (re-search-backward "^Received:")
291 (beginning-of-line) 291 (beginning-of-line)
292 ;; Is this always good? It's the only thing I saw when I checked 292 ;; Is this always good? It's the only thing I saw when I checked
293 ;; a few messages. 293 ;; a few messages.
294 (let ((eol (save-excursion (end-of-line) (point)))) 294 (let ((eol (save-excursion (end-of-line) (point))))
302 (setq temp (point)) 302 (setq temp (point))
303 (search-forward " ") 303 (search-forward " ")
304 (forward-char -1) 304 (forward-char -1)
305 ;; And add its postmaster to the list of addresses. 305 ;; And add its postmaster to the list of addresses.
306 (if (string-match "\\." (buffer-substring temp (point))) 306 (if (string-match "\\." (buffer-substring temp (point)))
307 (setq to (format "%s, postmaster@%s" 307 (setq to (format "%s, postmaster@%s"
308 to (buffer-substring temp (point))))) 308 to (buffer-substring temp (point)))))
309 ;; Also look at the message-id, it helps *very* often. 309 ;; Also look at the message-id, it helps *very* often.
310 (if (and (search-forward "\nMessage-Id: " nil t) 310 (if (and (search-forward "\nMessage-Id: " nil t)
311 ;; Not all Message-Id:'s have an `@' sign. 311 ;; Not all Message-Id:'s have an `@' sign.
312 (let ((bol (point)) 312 (let ((bol (point))
318 (progn 318 (progn
319 (setq temp (point)) 319 (setq temp (point))
320 (search-forward ">") 320 (search-forward ">")
321 (forward-char -1) 321 (forward-char -1)
322 (if (string-match "\\." (buffer-substring temp (point))) 322 (if (string-match "\\." (buffer-substring temp (point)))
323 (setq to (format "%s, postmaster@%s" 323 (setq to (format "%s, postmaster@%s"
324 to (buffer-substring temp (point))))))) 324 to (buffer-substring temp (point)))))))
325 (cond ((eq uce-mail-reader 'gnus) 325 (cond ((eq uce-mail-reader 'gnus)
326 ;; Does Gnus always have Lines: in the end? 326 ;; Does Gnus always have Lines: in the end?
327 (re-search-forward "^Lines:") 327 (re-search-forward "^Lines:")
328 (beginning-of-line)) 328 (beginning-of-line))
382 (or to (set-buffer-modified-p nil)) 382 (or to (set-buffer-modified-p nil))
383 ;; Run hooks before we leave buffer for editing. Reasonable usage 383 ;; Run hooks before we leave buffer for editing. Reasonable usage
384 ;; might be to set up special key bindings, replace standart 384 ;; might be to set up special key bindings, replace standart
385 ;; functions in mail-mode, etc. 385 ;; functions in mail-mode, etc.
386 (run-hooks 'mail-setup-hook 'uce-setup-hook)))) 386 (run-hooks 'mail-setup-hook 'uce-setup-hook))))
387 387
388 (defun uce-insert-ranting (&optional ignored) 388 (defun uce-insert-ranting (&optional ignored)
389 "Insert text of the usual reply to UCE into current buffer." 389 "Insert text of the usual reply to UCE into current buffer."
390 (interactive "P") 390 (interactive "P")
391 (insert uce-message-text)) 391 (insert uce-message-text))
392 392