XMailforum is a readonly knowledge archive now.

Registering as a new user or answering posts is not possible anymore.

Might the force be with you, to find here what you are looking for.

2019-09-20 - hschneider, Admin

Cookie Disclaimer: This forum uses only essential, anonymous session cookies (xmailforum*), nothing to be scared of.

XMail Forum -> How To Auto Insert Message On Subject

Reply to this topicStart new topicStart Poll

> How To Auto Insert Message On Subject
funganz
Posted: Jun 2 2009, 03:20 AM
Quote Post


Newbie
*

Group: Members
Posts: 8
Member No.: 3289
Joined: 2-June 09



For XMail can setup automatic insert subject when send e-mail or not.

For example auto insert “security” on subject after own client subject
when send e-mail

How to?

Thank!
PMEmail Poster
Top
sc4vengr
Posted: Jul 1 2009, 02:42 PM
Quote Post


Professional
*****

Group: Members
Posts: 206
Member No.: 461
Joined: 12-February 03



Hi, welcome to the forums.

This would require a custom filter that search for the line "subject:" during the DATA transfer.

I will write one when I have some free time.

-fred


--------------------
You + webcam - clothes - dignity = $
PMEmail Poster
Top
Sob
Posted: Jul 2 2009, 05:04 PM
Quote Post


Member
***

Group: Members
Posts: 53
Member No.: 2881
Joined: 19-April 08



I use the following with mailing list to include list name in subject, because I didn't find any option in XMail to do it automatically (I hope I didn't just overlook it smile.gif.

It's tested on Linux only.

It rewrites:
QUOTE
Subject: some subject

to:
QUOTE
Subject: [mylist] some subject

or does nothing if the identifier is already present, for example in:
QUOTE
Subject: Re: [mylist] some subject


I use it for outgoing mail sent from the list address:

filters/listsubj-mylist:
QUOTE
"/opt/xmail/bin/listsubj-filter"        "[mylist]"        "$(FILE)"

filters.out.tab:
QUOTE
"mylist@example.net"  "*"    "::/0"  "::/0"  "listsubj-mylist"


But now when I think about it, putting it in filter.in.tab for everything sent _to_ list address would probably be better, because it would be run only once for each mail. Doesn't really matter for me, I have only few subscribers anyway.

listsubj-filter.c:
QUOTE

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>

void fail(char *msg, int code) {
  //printf("FAIL: %s\n", msg);
  exit(code);
}

int main(int iArgCount, char *pszArgs[]) {
  FILE *fdata, *fmail;
  char line[1024];
  char tmp[1024];
  char mailfile[]="/tmp/lsfilter_XXXXXX";
  char separator[]="<<MAIL-DATA>>";
  int header=1;
  int rewritten=0;
  char *p;
  int fd = -1;

  if(iArgCount!=3) fail("usage: listsubj-filter <prefix> <message file>", 0);
  if((fdata=fopen(pszArgs[2], "r+"))==NULL) fail("Can't open input file", 0);
  if((fd=mkstemp(mailfile))<0) fail("Can't create mail temporary file", 0);
  if((fmail=fdopen(fd, "w+"))==NULL) {
    unlink(mailfile);
    close(fd);
    fail("Can't open mail temporary file", 0);
  }
  //
  while(fgets(line, sizeof(line), fdata)) {
    if(!header && !rewritten) {
      if(strncmp(line, "Subject:", 8)==0) {
        p=strstr(line, pszArgs[1]);
        if(p) {
          fclose(fmail);
          fclose(fdata);
          unlink(mailfile);
          exit(0);
        } else {
          sprintf(tmp, "Subject: %s", pszArgs[1]);
          strcat(tmp, line+8);
          strcpy(line, tmp);
          rewritten=1;
        }
      }
    }
    fputs(line, fmail);
    if(header && strncmp(line, separator, sizeof(separator)-1)==0) {
      header=0;
    }
  }
  //
  fseek(fmail, 0, 0);
  fseek(fdata, 0, 0);
  while(fgets(line, sizeof(line), fmail)) {
    fputs(line, fdata);
  }
  fclose(fmail);
  fclose(fdata);
  unlink(mailfile);
  //
  exit(7);
}


Compile with:
QUOTE
gcc -o listsubj-filter listsubj-filter.c

PMEmail Poster
Top
funganz
Posted: Sep 15 2009, 07:23 AM
Quote Post


Newbie
*

Group: Members
Posts: 8
Member No.: 3289
Joined: 2-June 09



Thank you, I will test it.
PMEmail Poster
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
« Next Oldest | XMail Server | Next Newest »

Reply to this topicStart new topicStart Poll