hellkvist.org Forum Index hellkvist.org
Discussions about the free software on hellkvist.org
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

simpler install issues

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    hellkvist.org Forum Index -> Peffisaur
View previous topic :: View next topic  
Author Message
buglerroller



Joined: 12 Jul 2005
Posts: 5

PostPosted: Tue Jul 12, 2005 9:07 pm    Post subject: simpler install issues Reply with quote

this will be the first of a simplified install of Peffisaur, after taking a look at everything offered in terms of docs/forum help im still left with a non working Peffisaur install.

took a while to get the latest/working mpack rpm's and that portion of a 100% working Peffisaur has been tackled. the setup that still has no easy to understand instructions is the email configurations in cPanel or other...
Back to top
View user's profile Send private message
buglerroller



Joined: 12 Jul 2005
Posts: 5

PostPosted: Tue Jul 12, 2005 10:30 pm    Post subject: Reply with quote

.filter was created in cPanel and the contents are;
Code:

$header_to: begins "p-"+++++++|/home/my_user/.procmailrc


Ran Filter Test via cPanal and the resultes were;
Code:

Filter Trace Results:

Condition is true: $header_to: begins p-
Return-path copied from sender
Sender      = my_user@server.host.com
Recipient   = my_user@server.host.com
Testing Exim filter file "/etc/vfilters/domain.com"

Pipe message to: /home/my_user/.procmailrc
Filtering set up at least one significant delivery or other action.
No other deliveries will occur.


.procmailrc contents;
Code:

LOGFILE=/home/my_user/tmp/recmail.log

:0
| /home/my_user/recmail.pl


recmail.pl contents;
Code:

#!/usr/bin/perl

use DBI;

$driver ="mysql";
$user = "my_user";
$password = "my_pass";
$munpack = "/usr/bin/munpack";
$msgstore = "/home/my_user/public_html/msgstore";
$reldir = "msgstore";

umask( 0 );

while ( $line = <STDIN> )
{
    @tmp = split( ": ", $line );

    if ( lc($tmp[0]) eq "to" )
    {
   chop( $tmp[1] );
   $to = $tmp[1];
    }
    elsif ( lc($tmp[0]) eq 'from' )
    {
   chop( $tmp[1] );
   $from = $tmp[1];
    }
    elsif ( lc($tmp[0]) eq 'subject' )
    {
   chop( $tmp[1] );
   $subject = $tmp[1];
    }
    elsif ( lc($tmp[0]) eq 'content-type' )
    {
   last;
    }
}

$dsn = "DBI:$driver:database='my_user'_psaur;host=localhost";
$dbh = DBI->connect( $dsn, $user, $password );
   
$id = isValid( $to, $from ) || die( "Not a valid user $to $from" );

$time = time();

$dirname = $msgstore . "/" . $$ . "_" . $time . "_email";
mkdir( $dirname, 0775 );

open(UNPACK,"| $munpack -q -C $dirname > $dirname/info.txt 2> /dev/null" )
    || die( "Could not start unpacker program");

print( UNPACK $line );

while ( $line = <STDIN> )
{
    print( UNPACK $line );
}

close( UNPACK );

$info = $dirname . '/info.txt';

open( INFO, $info ) || die( "Could not open info file [$!]" );

$size = 0;
while ( $line = <INFO> )
{
    @tmp = split( " ", $line );
    $tmp[1] = substr( $tmp[1], 1, length($tmp[1])-2 );
    $content{$tmp[0]} = $tmp[1];

    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
     $atime,$mtime,$ctime,$blksize,$blocks)
   = stat( $dirname . "/" . $tmp[0] );
    $size += $blksize * $blocks;
    $content_size{$tmp[0]} = $size;
}

close( INFO );

$mid = storeMessage( $to, $id, $subject, int( $size / 1024 ) );

foreach $file ( keys(%content) )
{
    storeContent( $mid, $file, $content{$file}, $content_size{$file} );
}

$txt = getTextForMid( $mid );
if ( length( $txt ) > 0 )
{
    setTextForMid( $mid, $txt );
}


sub storeContent
{
    ($mid, $file, $type, $size) = @_;
    $fname = $reldir  . "/" . $$ . "_" . $time . "_email/". $file;
    $query = "INSERT INTO content VALUES " .
   "(NULL, $mid, '$type', '$fname', $size )";
    chmod( 0775, $msgstore . "/" . $$ . "_" . $time . "_email/". $fname );
    $sth = $dbh->prepare($query) || die;
    $sth->execute();
}

sub setTextForMid
{
    ( $mid, $txt ) = @_;
    $txt = $dbh->quote( $txt );
    $query = "UPDATE messages SET textmsg=$txt WHERE id=$mid";
    $sth = $dbh->prepare($query) || die;
    $sth->execute();
}

sub getTextForMid
{
    ($mid) = @_;

    $query = "SELECT fname FROM content WHERE mid=$mid && ".
   "contenttype='text/plain'";
    $sth = $dbh->prepare($query) || die;
    $sth->execute();
   
    if ( @row = $sth->fetchrow() )
    {
   $fname = $row[0];
   open( TXTFILE, $msgstore . "/../" . $fname );
   @content = <TXTFILE>;
   $txt = join('', @content);
   return $txt;
    }
    return "";
}

sub storeMessage
{
    ($to, $sid, $subject, $size ) = @_;
    $subject = $dbh->quote($subject);
    $to = $dbh->quote($to);
    $query = "INSERT INTO messages VALUES " .
   "(NULL, $sid, 1, $to, $subject, NOW(), 'email', '0.0.0.0', 0, 0, '', 0  )";
    $sth = $dbh->prepare($query) || die;
    $sth->execute();

    $query = "SELECT LAST_INSERT_ID() FROM messages";
    $sth = $dbh->prepare($query) || die;
    $sth->execute();
    @row = $sth->fetchrow();
    $id = $row[0];

    $query = "UPDATE users SET nkbytes=nkbytes+$size, ".
   " lastupload=NOW(), ".
       " nuploads=nuploads+1 WHERE id=$sid";
    $sth = $dbh->prepare($query) || die;
    $sth->execute();

    return $id;
}

#isValid
#to-address is on form p-<number>@domain.com
#from-address is on form <MSISDN>@domain.com
sub isValid
{
    ($to, $from) = @_;
    $end = index( $to, "@" );
    $start = index( $to, "p-" );
    $pwd = substr( $to, $start + 2, $end - $start - 2 );
   
    @froms = split( "@", $from );
    $msisdn = $froms[0];
    if ( ($index = index( $msisdn, "<" )) >= 0 )
    {
   $msisdn = substr( $msisdn, $index + 1 );
    }

    $query = "SELECT id FROM users WHERE phonepwd='$pwd'";
    $sth = $dbh->prepare($query) || die;
    $sth->execute();

    $id = 0;   
    if ( @row = $sth->fetchrow() )
    {
   $id = $row[0];
    }
    $sth->finish();

    $id || die( "msisdn is $msisdn and pwd is $pwd" );

    return $id;
}


The three files have 777 properties and are located in;
/home/my_user/

The domain local default email address is;
my_user

When a user sends email to;
p-xxxxxxxx@domain.com
The email just sits in the box of the my_user account.

Is a .forward with the contents needed as seen in another thread?;
Code:

|/usr/bin/procmail


Also in no log file can be found in;
/home/my_user/tmp

Is there something missing?
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    hellkvist.org Forum Index -> Peffisaur All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group