views:

2479

answers:

12

I'm working on an anti-spam project (centmail) that involves having the sender use a client plugin that adds a custom header (as well as a signature, but that part's easier). The general problem is to add an email header to your outgoing mail where the contents of the header field is determined dynamically for each message.

Surprisingly, this does not seem to be possible in Pine/Alpine. Pine lets you specify a filter script for outgoing mail but only the body and not the headers get passed through it. You can of course define custom headers in the Pine settings but I see no way to dynamically change the contents of them.

I'd be grateful to hear how to do this in other email clients (Thunderbird, Outlook, Evolution, Mutt, etc). And of course if I'm wrong about Pine.

+5  A: 

The Thunderbird plugin Enigmail controls the headers for outgoing mail. So that's an existence proof that it's possible in Thunderbird.

dreeves
+27  A: 

You can do it in Eudora.

You can do it programmatically in Outlook with a custom form.

You can do it in Mozilla from about:config.

Scott Hanselman
Does the Mozilla solution work for actually programmatically updating the contents of a custom header field for each email sent?
dreeves
+21  A: 

Although it's not a plugin in the strictest sense, you could make a proxy SMTP server which would modify the e-mails - e.g. something like the AVG Outgoing E-mail Scanner. This would have the advantage of working with many e-mail clients; you could also make a plug-in which would communicate with the proxy on one side and the e-mail UI on the other.

Piskvor
A: 

For all mail clients that support using an external editor, you could have a script that add a specific header to the template that gets send to the editor. In mutt, there is a configuration parameter called edit_headers that add a common set of headers so it would be easy to add your own. There is also another parameter called my_hdr which could be used. Mutt does support the ` backtick `` notation to run external commands.

It would be better to be able to specify one's own template but it is not possible yet.

Keltia
+2  A: 

I dug this from the old parts of Brain tunes to other things...

I think that approach is to go to config SENDMAIL and do via [bash/etc] scripting if i understand correctly.

Root file http://snap.nlc.dcccd.edu/reference/sysadmin/julian/ewtoc.html

SendMail Configuration

Header Declarations http://snap.nlc.dcccd.edu/reference/sysadmin/julian/ch04/061-064.html#Heading22

http://snap.nlc.dcccd.edu/reference/sysadmin/julian/ch04/078-080.html

The format of the header lines is defined by the H line. The syntax of this line is

H[c ?c mflagsc ?]c hnamec :c htemplate

Continuation lines in this specification are inserted directly into the outgoing message. The htemplate is macro-expanded before it is inserted into the message. If the expansion is empty, the header line is not included. If the mflags (surrounded by question marks) are specified, at least one of the specified flags must be stated in the mailer definition for this header to be automatically output. If one of these headers is in the input, it is directed to the output regardless of these flags.

Special Header Lines Several header lines have special interpretations defined by the configuration file. Others have interpretations built into sendmail that cannot be changed without changing the code. The built-in features are described in the following list:

• Return-Receipt-To: If this header is sent, a message will be sent to any specified names when the final delivery is complete. The mailer must have the l flag (local delivery) set in the mailer descriptor. • Errors-To: If errors occur anywhere during processing, this header sends error messages to the listed names rather than to the sender. Use this header line for mailing lists so that errors are returned to the list administrator. • To: If a message comes in with no recipients listed in the message (in a To:, CC:, or BCC: line), sendmail adds an Apparently To: header line for each recipient specified on the sendmail command line.

+5  A: 

I agree with Piskvor. I would implement it as a proxy SMTP server which would yield a number of benefits:

  1. You'd not be constrained to any one email client and therefore limited by its APIs (if any)
  2. It can be applied on the mail server end, therefore installation and deployment headaches are eliminated
Conrad
+4  A: 

Emacs can do this programmatically. You can create a buffer (get-buffer-create), fill it with header information, and call mail-send non interactivelly (set mail-interactive to nil).

Example of buffer content (header+body) to use with mail-send:

From: "Toto" <[email protected]>
To: [email protected]
Subject: Something
BCC: [email protected]
--text follows this line--

Hello, how are you?

You can also alter every outgoing email (header + body) by adding a hook to mail-send-hook.

Sébastien RoccaSerra
+3  A: 

This has already been asked specifically about Thunderbird:

The top answer contains the code to modify the headers in plain xul/js.

Colin Pickard
+1  A: 

It occurs to me that since pine is open source, if this functionality is important to you for this program you could try contributing to the project to add the feature.

Joel Coehoorn
If you do that you totally get the bounty for this question! :)
dreeves
+1  A: 

One thing that you might want to look into is using pseudo-headers instead of headers. Becasue pine/alpine let you specify a filter program for the email to go through, you can add the header to the body at the beginning, which should be easy enough to process. I'm not sure if it would fit your purposes exactly though since I do not know what type of system you are putting together.

I learned about pseudo-headers through their use in the Debian BTS System.

Answering the question, I use GMail, and you can't edit the headers programmatically (I would be interested to see a webmail that lets you). You can't even filter on custom headers like X-List, it's quite annoying.

jamuraa
+1  A: 

Something is wrong with general idea to plug mail clients for custom headers.

There is just to many clients out there. Including different versions, on different systems.

Good thing behind header+body format is that all non-user, server and routing specific data is hidden from the user. And that idea is important to follow. I don't think that user should be bothered with some custom, server related headers.

Also, the data that you are trying to append is, in fact, user specific data. Like signature. It verifies validity of sender. There is no reason to hide it from user.

Signing of email data is well-known process, used by PGP, SMIME, etc. There is probably more mail clients allowing such actions (verify and sign by external programs) than allowing to add or modify custom mail headers.

Custom headers should be modified by mail servers; user data by mail clients.

I think that you sholud put your data in message or message part.

dmajkic
+1  A: 

One way to make it work in pine without modifying pine itself or modifying the mail server is to have pine deliver via a command line program (traditionally /usr/sbin/sendmail or the like) and have the called program be a wrapper for the original program. Then you can add whatever header you need.

That's ugly though, it certainly wouldn't scale for a whole user base.

jj33