<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/assets/atom.xsl" type="text/xsl"?><feed
	xmlns="http://www.w3.org/2005/Atom"
	xmlns:thr="http://purl.org/syndication/thread/1.0"
	xml:lang="en-US"
	><title>Sacha Chua - category - gnus</title>
	<subtitle>Emacs, sketches, and life</subtitle>
	<link rel="self" type="application/atom+xml" href="https://sachachua.com/blog/category/gnus/feed/atom/index.xml" />
  <link rel="alternate" type="text/html" href="https://sachachua.com/blog/category/gnus" />
  <id>https://sachachua.com/blog/category/gnus/feed/atom/index.xml</id>
  <generator uri="https://11ty.dev">11ty</generator>
	<updated>2008-06-08T00:19:10Z</updated>
<entry>
		<title type="html">Emacs Gnus: Filter Spam</title>
		<link rel="alternate" type="text/html" href="https://sachachua.com/blog/2008/06/emacs-gnus-filter-spam/"/>
		<author><name><![CDATA[Sacha Chua]]></name></author>
		<updated>2008-06-08T04:19:10Z</updated>
    <published>2008-06-08T00:19:10Z</published>
    <category term="emacs" />
<category term="wickedcoolemacs" />
<category term="elisp" />
<category term="gnus" />
<category term="mail" />
		<id>https://sachachua.com/blog/?p=4913</id>
		<content type="html"><![CDATA[<p>(draft for an upcoming book called <a href="https://sachachua.com/blog/category/wickedcoolemacs">Wicked Cool Emacs</a>)</p>
<div class="outline-4">
<p>Ah, spam, the bane of our Internet lives. There is no completely<br>
reliable way to automatically filter spam. Spam messages that slip<br>
through the filters and perfectly legitimate messages that get<br>
labelled spam are all part of the occupational hazards of using the<br>
Internet.
</p>
<p>
The fastest way to filter spam is to use an external spam-filtering<br>
program such as Spamassassin or Bogofilter, so your spam can be<br>
filtered in the background and you don&#8217;t have to spend time in Emacs<br>
filtering it yourself. In an ideal world, this would be done on the<br>
mail server so that you don&#8217;t even need to download unwanted<br>
messages. If your inbox isn&#8217;t full of ads for medicine or stocks, your<br>
mail server is probably doing a decent job of filtering the mail for<br>
you.
</p>
<h3>Server-based mail filtering</h3>
<p>
As spam filtering isn&#8217;t an exact science, you&#8217;ll want to find out how<br>
you can check your spam folder for misclassified mail. If you download<br>
your mail through POP, find out if there&#8217;s a webmail interface that<br>
will allow you to check if any real mail has slipped into the junk<br>
mail pile. If you&#8217;re on IMAP, your mail server might automatically<br>
file spam messages in a different group. Here&#8217;s how to add the spam<br>
group to your list of groups:
</p>
<ol>
<li>
Type M-x gnus to bring up the group buffer.
</li>
<li>
Type ^ (gnus-group-enter-server-mode).
</li>
<li>
Choose the nnimap: entry for your mail server and press RET (gnus-server-read-server).
</li>
<li>
Find the spam or junk mail group if it exists.
</li>
<li>
Type u (gnus-browse-unsubscribe-current-group) to toggle the subscription. Subscribed groups will appear in your M-x gnus screen if they contain at least one unread message.<p></p>
</li>
</ol>
<p>Another alternative is to have all the mail (spam and non-spam)<br>
delivered to your inbox, and then let Gnus be in charge of filing it<br>
into your spam and non-spam groups. If other people manage your mail<br>
server, ask them if you can have your mail processed by the spam<br>
filter but still delivered to your inbox. If you&#8217;re administering your<br>
own mail server, set up a spam filtering system such as SpamAssassin<br>
or BogoFilter, then read the documentation of your spam filtering<br>
system to find out how to process the mail.
</p>
<p>
Spam filtering systems typically add a header such as &#8220;X-Spam-Status&#8221;<br>
or &#8220;X-Bogosity&#8221; to messages in order to indicate which messages are<br>
spam or even how spammy they are. To check if your mail server tags<br>
your messages as spam, open one of your messages in Gnus and type C-u<br>
g (gnus-summary-show-article) to view the complete headers and<br>
message. If you find a spam-related header such as X-Spam-Status, you<br>
can use it to split your mail. Add the following to your ~/.gnus:
</p>
<p></p><pre>
 (setq spam-use-regex-headers t) ;; (1)
 (setq spam-regex-headers-spam "^X-Spam-Status: Yes")   ;; (2)
 (require 'spam) ;; (3)
 (spam-initialize) ;; (4)
</pre>
<p></p>
<p>
This configures spam.el to detect spam based on message<br>
headers(1). Set spam-regex-headers-spam to a regular expression<br>
matching the header your mail server uses to indicate spam.(2) This<br>
configuration should be done before the spam.el library is loaded(3)<br>
and initialized(4), because spam.el uses the spam-use-* variables to<br>
determine which parts of the spam library to load.
</p>
<p>
In order to take advantage of this, you&#8217;ll also need to add a rule<br>
that splits spam messages into a different group. If you haven&#8217;t set<br>
up mail splitting yet, read qthe instructions on setting up fancy mail<br>
splitting in &#8220;Project XXX: Organize mail into groups&#8221;. Add (:<br>
spam-split) to either nnmail-split-fancy or nnimap-split-fancy,<br>
depending on your configuration. For example, your ~/.gnus may look<br>
like this:
</p>
<pre>
(setq nnmail-split-fancy
'(
;; ... other split rules go here ...
(: spam-split)
;; ... other split rules go here ...
"mail.misc")) ; default mailbox
</pre>
</div>
<p>(draft for an upcoming book called <a href="https://sachachua.com/blog/category/wickedcoolemacs">Wicked Cool Emacs</a>, more to come!)</p>
<p>You can <a href="https://sachachua.com/blog/2008/06/emacs-gnus-filter-spam/#comment">view 1 comment</a> or <a href="mailto:sacha@sachachua.com?subject=Comment%20on%20https%3A%2F%2Fsachachua.com%2Fblog%2F2008%2F06%2Femacs-gnus-filter-spam%2F&body=Name%20you%20want%20to%20be%20credited%20by%20(if%20any)%3A%20%0AMessage%3A%20%0ACan%20I%20share%20your%20comment%20so%20other%20people%20can%20learn%20from%20it%3F%20Yes%2FNo%0A">e-mail me at sacha@sachachua.com</a>.</p>]]></content>
		</entry>
</feed>