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.

Community
  • 1
  • 1
dreeves
  • 26,430
  • 45
  • 154
  • 229
  • I'm more and more sure I'm not wrong about Pine. It actually has an option (_INCLUDEALLHDRS_) to pass the headers to the outgoing filter script but it still doesn't let the script change the headers in the actual sent email. – dreeves Nov 19 '08 at 01:06
  • It seems that Mutt has the same problem as Pine. – dreeves Dec 02 '08 at 05:49
  • Since this is one of the first questions offering a bounty, shouldn't it be a "normal" question, not a community wiki? – Hosam Aly Jan 27 '09 at 09:17
  • 550 rep points: that's a lot of keyboards full of drool! – Mitch Wheat Jan 27 '09 at 10:55
  • Any consequences bounty-wise of this being a community wiki? It's doubly ironic: I marked it a CW because I started using StackOverflow before the tooltip explaining the consequences reputation-wise. And I posted a big bounty before the bounty instructions said anything about "highest voted answer". – dreeves Jan 27 '09 at 23:57
  • (But that's fine; these answers are very valuable to me!) – dreeves Jan 27 '09 at 23:58
  • How did the bounty on this get to be 550, when the limit is 500? – skiphoppy Jan 30 '09 at 19:09
  • @skiphoppy: SO adds a bonus of 50 to the bounty, so the effective range is 100 to 550. – Michael Myers Jan 30 '09 at 21:47
  • this bounty thing still seems like 'cheating' to me - to get points from just answering generous bountied questions. but for a question like this the questioner obviously wants as many answers as possible and thats why he is offering one. most people answering already know they cant 'win' – Simon_Weaver Jan 31 '09 at 05:01

12 Answers12

27

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.

guerda
  • 23,388
  • 27
  • 97
  • 146
Scott Hanselman
  • 17,712
  • 6
  • 74
  • 89
  • Does the Mozilla solution work for actually programmatically updating the contents of a custom header field for each email sent? – dreeves Jan 29 '09 at 19:27
20

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 left the building
  • 91,498
  • 46
  • 177
  • 222
5

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

dreeves
  • 26,430
  • 45
  • 154
  • 229
5

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
dreeves
  • 26,430
  • 45
  • 154
  • 229
Rad
  • 8,336
  • 4
  • 46
  • 45
4

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" <toto@toto.net>
To: somebody@somewhere.net
Subject: Something
BCC: sebastien.rocca-serra@f4-group.com
--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
  • 16,731
  • 8
  • 50
  • 54
3

This has already been asked specifically about Thunderbird:

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

Community
  • 1
  • 1
Colin Pickard
  • 45,724
  • 13
  • 98
  • 148
2

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.

1

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
  • 399,467
  • 113
  • 570
  • 794
1

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
  • 3,419
  • 25
  • 29
1

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
  • 3,448
  • 1
  • 18
  • 24
1

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
  • 7,543
  • 2
  • 38
  • 42
0

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.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
Keltia
  • 14,535
  • 3
  • 29
  • 30