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 -> Archive Outgoing mails

Reply to this topicStart new topicStart Poll

> Archive Outgoing mails, Have a copy of all the outgoing mails
aju_rathod
Posted: Jun 10 2006, 09:37 AM
Quote Post


Advanced Member
****

Group: Members
Posts: 137
Member No.: 1858
Joined: 17-December 05



Hi,

I want a copy of all the outgoing mails on the server. This is the requirement of the organization. The configuration is as follows but still it doesnt works.

filter.out.tab is as follows:


"*" "*" "0.0.0.0/0" "0.0.0.0/0" "copy.tab"

copy.tab is as follows

"\var\MailRoot\filters\copy.pl" "@@FILE"

Copy.pl is as follows
#!/usr/bin/perl
require MIME::Lite;

system('export MAIL_ROOT=/var/MailRoot');

$mess = $ARGV[0];
$tmess = $mess;
#$path_to_box ="/var/MailRoot/domains/synchronresearch.com/outgoing/Maildir/new";
$boss = 'outgoing@synchronresearch.com';
$action = 5;
open(FILE,$mess);
@mess = <FILE>;
close(FILE);

$mess = join('',@mess);
$mess = split(/<<MAIL-DATA>>\r\n/,$mess);
@mess = split('\n',$mess);
$cnt = scalar(@mess);
for ($i=0; $i<$cnt; $i++){
if (@mess[$i] =~ m/Subject/g){@mess[$i] =~ s/Subject\: /Subject\: \[copy\] /g;}
}

@tmess = split('/',$tmess);
$tcnt = scalar(@tmess);

#this will copy to local maildir
#open(FILE,">$path_to_box@tmess[$tcnt-1]");
#for ($i=0; $i<$cnt; $i++){
#print FILE "@mess[$i]\n";
#}
#close(FILE);

#this will send e-mail
$msg = MIME::Lite->new(
From => 'synchronresearch.com',
To => $boss,
Subject => 'Copy',
Type => 'multipart/related');
$msg->attach(
Type => 'text/plain; charset=windows-1250',
Data => $mess);
MIME::Lite->send('smtp', "127.0.0.1", Timeout=>60);

What could be the reason?

Regarsd,
Ahay Rathod.

PMEmail Poster
Top
atomant
Posted: Jun 10 2006, 03:19 PM
Quote Post


No - I'm not an answering script ...
Group Icon

Group: Admin
Posts: 1776
Member No.: 427
Joined: 18-January 03



- do you have a module MIME::Lite isntalled ?
- change
From => 'synchronresearch.com',
to
From => 'something@synchronresearch.com',

- what is not working?
- what errors?
- anything in the logs?
- run Xmail in debug mode to see what is going on


--------------------
Bye,
Sasa



-------------------------------------------------------------------

All electric machines work on smoke...when the smoke escape from machines, they don't work anymore
Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming or what?"
PMEmail PosterUsers WebsiteICQ
Top
aju_rathod
Posted: Jun 10 2006, 04:33 PM
Quote Post


Advanced Member
****

Group: Members
Posts: 137
Member No.: 1858
Joined: 17-December 05




I am not getting the copy of outgoing messages in the mailbox of Outgoing@synchronresearch.com

Following is the ouput of logs


Jun 10 20:50:50 synchronresearch last message repeated 7 times
Jun 10 20:51:30 synchronresearch last message repeated 8 times
Jun 10 20:51:31 synchronresearch XMail[23084]: Filter error (-97): Sender = "aja
y@synchronresearch.com" Recipient = "postmaster@interveinlab.com" Filter = "\var
\MailRoot\filters\copy.pl"
Jun 10 20:51:35 synchronresearch pam_timestamp_check: pam_timestamp: `/var/' per
missions are lax
Jun 10 20:52:10 synchronresearch last message repeated 7 times
Jun 10 20:53:15 synchronresearch last message repeated 13 times
Jun 10 20:54:20 synchronresearch last message repeated 13 times
Jun 10 20:55:00 synchronresearch last message repeated 8 times
Jun 10 20:55:01 synchronresearch crond(pam_unix)[23173]: session opened for user root by (uid=0)
Jun 10 20:55:02 synchronresearch crond(pam_unix)[23173]: session closed for user root
Jun 10 20:55:05 synchronresearch pam_timestamp_check: pam_timestamp: `/var/

Following is the output of running Xmail in debug mode


[PSYNC/MASQ] MasqDomain = "synchronresearch.com,synchronresearch.com" - RmtDomain = "synchronresearch.com" - RmtName = "synchron"
[PSYNC] entry
[PSYNC/MASQ] MasqDomain = "litchtech.net,litchtech.net" - RmtDomain = "litchtech.net" - RmtName = "litchtec"
[PSYNC] entry
[PSYNC/MASQ] MasqDomain = "interveinlab.com,interveinlab.com" - RmtDomain = "interveinlab.com" - RmtName = "intervei"
[PSYNC] exit
[PSYNC] exit
[PSYNC] exit
[PSYNC] entry
[PSYNC/MASQ] MasqDomain = "synchronresearch.com,synchronresearch.com" - RmtDomain = "synchronresearch.com" - RmtName = "synchron"
[PSYNC] entry
[PSYNC/MASQ] MasqDomain = "interveinlab.com,interveinlab.com" - RmtDomain = "interveinlab.com" - RmtName = "intervei"
[PSYNC] entry
[PSYNC/MASQ] MasqDomain = "litchtech.net,litchtech.net" - RmtDomain = "litchtech.net" - RmtName = "litchtec"
[PSYNC] exit
[PSYNC] exit
[PSYNC] exit
execv error: cmd='\var\MailRoot\filters\copy.pl'
Filter error (-97): Sender = "rahul@synchronresearch.com" Recipient = "drshiv@synchronreseach.com" Filter = "\var\MailRoot\filters\copy.pl"
MX records for domain "synchronreseach.com" not found, trying direct.
SMAIL SMTP-Send FF = "synchronreseach.com" SMTP = "192.168.0.11" From = "rahul@synchronresearch.com" To = "drshiv@synchronreseach.com"
<<
ErrCode = -40
ErrString = Invalid server address
ErrInfo = synchronreseach.com
SMAIL SMTP-Send FF = "synchronreseach.com" SMTP = "192.168.0.11" From = "rahul@synchronresearch.com" To = "drshiv@synchronreseach.com" Failed !
SMTP-Error = "417 Temporary delivery error"
SMTP-Server = "synchronreseach.com"


I am not getting the copy of outgoing messages with the configuration specified in Copy.pl file.

PMEmail Poster
Top
atomant
Posted: Jun 10 2006, 06:24 PM
Quote Post


No - I'm not an answering script ...
Group Icon

Group: Admin
Posts: 1776
Member No.: 427
Joined: 18-January 03



QUOTE
ErrCode = -40
ErrString = Invalid server address
ErrInfo = synchronreseach.com
SMAIL SMTP-Send FF = "synchronreseach.com" SMTP = "192.168.0.11" From = "rahul@synchronresearch.com" To = "drshiv@synchronreseach.com" Failed !
SMTP-Error = "417 Temporary delivery error"
SMTP-Server = "synchronreseach.com"


It says that domain synchronresearch.com does not exists. Looks like you have dns problem.
When I telnet to synchronresearch.com I get:
QUOTE
mig29# telnet synchronresearch.com 25
Trying 66.45.240.50...
Connected to synchronresearch.com.
Escape character is '^]'.
220-integer2.yellowbusinesspages.com ESMTP Exim 4.52 #1 Sat, 10 Jun 2006 13:22:41 -0400
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.


This is not Xmail server running but Exim. Port 25 blocked??


--------------------
Bye,
Sasa



-------------------------------------------------------------------

All electric machines work on smoke...when the smoke escape from machines, they don't work anymore
Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming or what?"
PMEmail PosterUsers WebsiteICQ
Top
aju_rathod
Posted: Jun 11 2006, 10:09 AM
Quote Post


Advanced Member
****

Group: Members
Posts: 137
Member No.: 1858
Joined: 17-December 05



Port 25 is not blocked, it is open on my gateway for my internal mail server address which is 192.168.0.11. and what you are getting is you are getting from my main server which is hosted on 66.45.240.50. I want a copy of all the outgoing messages. The copy.pl file doesnt put the copy og outgoing messages in the mail directory of outgoing@synchronresearch.com. Mail server works fine , there is no any problem in that. What i did for a copy that i already mentioned.

Thanks for the support,
Ajay Rathod.
PMEmail Poster
Top
atomant
Posted: Jun 12 2006, 05:29 AM
Quote Post


No - I'm not an answering script ...
Group Icon

Group: Admin
Posts: 1776
Member No.: 427
Joined: 18-January 03



As in my prevous message: Xmail says that synchronresearch.com is an invalid address. So either it is or Xmail cannot resolve it correctly. If you have a local dns server or using ISP's dns server you can put all of them in the dnsroots file.


--------------------
Bye,
Sasa



-------------------------------------------------------------------

All electric machines work on smoke...when the smoke escape from machines, they don't work anymore
Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming or what?"
PMEmail PosterUsers WebsiteICQ
Top
aju_rathod
Posted: Jun 13 2006, 06:43 AM
Quote Post


Advanced Member
****

Group: Members
Posts: 137
Member No.: 1858
Joined: 17-December 05



Sorry to say but what you are looking at is synchronreseach.com and not synchronresearch.com. My domain is synchronresearch.com. So there is no any problem of domain. That message shows the information about the bounced mail.

Regards,
Ajay Rathod
PMEmail Poster
Top
bim
Posted: Jun 13 2006, 10:25 PM
Quote Post


Advanced Wizard
**********

Group: Members
Posts: 489
Member No.: 297
Joined: 6-October 02



synchronreseach.com is from your logs:

QUOTE
Recipient = "drshiv@synchronreseach.com"


And keep in mind that filters.out.tab will only work for remotely delivered mails. So if the mailser that is running this script, is also the mailserver for synchronresearch.com, then internal mails sent from one synchronresearch.com-address to an other synchronresearch.com-address won't be logged.

...but if this mailserver isn't the mailserver hosting mailboxes for synchronresearch.com, then keep in mind that your script will cause an endless loop since the mails you log, will also be logged, which will also be logged, which...

And for testing: get yourself a copy of a message from the server. I think this will do the trick:
CODE
"/bin/cp" "@@FILE" "/home/user/testFile.txt"


and now call your script from the command line with the location of the file you just saved as a parameter... If anything is wrong in your script, then you should now get a nice error message telling you exactly what.
PM
Top
NomadCF
Posted: Jun 20 2006, 01:40 PM
Quote Post


Wizard
*********

Group: Members
Posts: 428
Member No.: 434
Joined: 21-January 03



Here what we use for archiving all sent messages.

filters.in.tab
CODE

"*"     "*"     "0.0.0.0/0"     "0.0.0.0/0"     "record-in.tab"

filters.out.tab
CODE

"*"     "*"     "0.0.0.0/0"     "0.0.0.0/0"     "record-out.tab"

record-in.tab
CODE

"/var/MailRoot/filters/record.sh"       "@@RFROM"       "@@RRCPT"       "@@FILE"        "IN"

record-out.tab
CODE

"/var/MailRoot/filters/record.sh"       "@@RFROM"       "@@RRCPT"       "@@FILE"        "OUT"

record.sh
CODE
#!/bin/bash
Storage_path="/var/MailRoot/archive/%InOut%/%Letter%/%Username%/%Year%/%Month%/%Day%/"

###########
#### @@FROM     @@RCPT  @@FILE  "IN/OUT"
###########
if [ "$4" = "IN" ]; then
From=$2
else
From=$1
fi

INOUT=$4
File=$3
From=`echo "$From" | tr "[:upper:]" "[:lower:]"`

Username=`echo "$From" | awk -F\@ '{print $1}'`
Username_Letter=${Username:0:1}

Date_day=`date +%d`
Date_month=`date +%m`
Date_year=`date +%G`
Date_epoch=`date +%s`
## to get back perl -le "print scalar gmtime $Date_epoch"

Storage_path=`echo "$Storage_path" | sed -e 's/%InOut%/'$INOUT'/g'`
Storage_path=`echo "$Storage_path" | sed -e 's/%Letter%/'$Username_Letter'/g'`
Storage_path=`echo "$Storage_path" | sed -e 's/%Username%/'$Username'/g'`
Storage_path=`echo "$Storage_path" | sed -e 's/%Year%/'$Date_year'/g'`
Storage_path=`echo "$Storage_path" | sed -e 's/%Month%/'$Date_month'/g'`
Storage_path=`echo "$Storage_path" | sed -e 's/%Day%/'$Date_day'/g'`

dirs=`echo "$Storage_path" | /bin/awk -F/ '{print NF }'`

for i in `seq 1 $dirs`;
do

 mk=`echo "$Storage_path" | /bin/awk -F/ '{print $'$i'}'`

 if [ "$mk" != "." ]; then
  if [ "$mk" != "" ]; then
   mk_path="$mk_path/$mk"
   if [ -d "$mk_path" ]; then
   # echo "Skipping $mk_path"
    loop=""
   else
    mkdir "$mk_path"
   fi
  fi
  else
  if [ "$i" = "1" ]; then
   mk_path="$mk"
  fi
 fi

done

run=`cp "$File" "$Storage_path"`



This will create a storage structure like this.
CODE

+ /var
+/MailRoot
 +/archive/
  +%InOut%
   +/%Letter%
    +/%Username%
     +/%Year%
      +/%Month%
       +/%Day%/MESSAGE


Or as a real example of a message send to no_spam@nomadcf.com on 6/20/06 would look like this.

CODE

+ /var
+/MailRoot
 +/archive/
  +/IN
   +/n
    +/no_spam
     +/2006
      +/06
       +/20/MESSAGE


This is by no means an ideal archiving system but it's simple and works for single domain hosts. And it's easy to script web interfaces for so people can allow there users to restore or call up old emails (but not remove them form the archive).


--------------------
-- Chris L. Franklin --
www.NomadCF.com

All my scripts are written for linux servers.
My XMail scripts
PMEmail PosterUsers WebsiteAOL
Top
aju_rathod
Posted: Jun 26 2006, 10:05 AM
Quote Post


Advanced Member
****

Group: Members
Posts: 137
Member No.: 1858
Joined: 17-December 05



Hi,

Thanks for the information. I followed all the information as mentioned above but still there is no single mail is /var/MailRoot/archive. Do i need to change anything in record.sh ?

Regards,
Ajay Rathod
PMEmail Poster
Top
NomadCF
Posted: Jun 26 2006, 01:36 PM
Quote Post


Wizard
*********

Group: Members
Posts: 428
Member No.: 434
Joined: 21-January 03



is record.sh chown'ed so it's executable ?

have you tried running this by hand ?

example :
CODE

/var/MailRoot/filters/record.sh "TEST@remotedomain"       "USER@LOCALDOMAIN"       "FILE_TO_ARCHIVE_LOCATION"        "IN"


So don't forget those are TABs in those filter.*.tab files !


--------------------
-- Chris L. Franklin --
www.NomadCF.com

All my scripts are written for linux servers.
My XMail scripts
PMEmail PosterUsers WebsiteAOL
Top
aju_rathod
Posted: Jun 26 2006, 02:37 PM
Quote Post


Advanced Member
****

Group: Members
Posts: 137
Member No.: 1858
Joined: 17-December 05



Hi,

I chown to root and chmod 777 for record.sh. I ran the script by hand but nothing is the output. And I already gave the TABs in filters.*.tab. What is the above code which you specified.

/var/MailRoot/filters/record.sh "TEST@remotedomain" "USER@LOCALDOMAIN" "FILE_TO_ARCHIVE_LOCATION" "IN"

Where do i need to put this lines?

Regards,
Ajay Rathod.
PMEmail Poster
Top
NomadCF
Posted: Jun 26 2006, 02:45 PM
Quote Post


Wizard
*********

Group: Members
Posts: 428
Member No.: 434
Joined: 21-January 03



no where just try running it from the command line and see if it works.
(don't forget to replace FILE_TO_ARCHIVE_LOCATION with a real file and USER@LOCALDOMAIN with a real localuser and domain)


--------------------
-- Chris L. Franklin --
www.NomadCF.com

All my scripts are written for linux servers.
My XMail scripts
PMEmail PosterUsers WebsiteAOL
Top
aju_rathod
Posted: Jun 27 2006, 06:03 AM
Quote Post


Advanced Member
****

Group: Members
Posts: 137
Member No.: 1858
Joined: 17-December 05



Hi,

Yes the script is working by hand but where are the mails? The structure of the folder is as follows:

/var/MailRoot/archive/IN/letter/username/year/month/date/
/var/MailRoot/archive/OUT/letter/username/year/month/date/

but there are no mails in this directory. Then where does the mails goes?

Thanks and Regards,
Ajay Rathod.
PMEmail Poster
Top
NomadCF
Posted: Jun 27 2006, 11:41 AM
Quote Post


Wizard
*********

Group: Members
Posts: 428
Member No.: 434
Joined: 21-January 03



So your saying it did create the directory structure but didn't copy mail into it.

Is SELinux turned on,on your machine ?
Where there any errors when you tried running it by hand ?
are you able to copys files yuor self in any of the "created" directory structure ?


--------------------
-- Chris L. Franklin --
www.NomadCF.com

All my scripts are written for linux servers.
My XMail scripts
PMEmail PosterUsers WebsiteAOL
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
« Next Oldest | Scripting Corner | Next Newest »

Reply to this topicStart new topicStart Poll