You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Plugin-Writing Tips

These tips may be useful to developers of SpamAssassin plugins.

Setting Output Headers

If you want to add custom headers in the rewritten mail message, the Mail::SpamAssassin::PerMsgStatus::set_tag() API is the way to do it.

The way it works is, you add a line like this to the plugin configuration file, or the user's preferences file:

  add_header all Test-Tag the tag says _MYTAG_

and in the plugin code, call set_tag() like so:

  $permsgstatusobject->set_tag ("MYTAG", "hello world");

(obviously you want something interesting in there, like results of a scan etc.) The resulting output will look like:

  X-Spam-Status: [usual stuff]
  X-Spam-Test-Tag: the tag says hello world

You can also get the value of a tag using the Mail::SpamAssassin::PerMsgStatus::get_tag() API from inside a plugin, although note that some of the tags will not be filled in until after the scan completes, and may not be available.

  • No labels