🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rocksolid.nodes.announce
Article #447

Features added for InterBBS mail

#447
From: Retro Guy
Date: Wed, 09 Aug 2023 17:21
60 lines
3159 bytes
The following features have been added to interBBS Mail:

Check for a KEY first, before sending a notification post of where to find your key.

Move incoming BBSMAIL posts to /processed or /failed for future inspection if necessary, then prune those directories of messages > 30 days old.

Try to get the KEY for a target domain when a user tries to send mail to that domain. If we can get the KEY, the mail succeeds. If we can NOT get the KEY, the mail fails with a useable message to the sender.

To apply these changes, update:

mail.php
interBBS_mail.php

Then add the following two functions to newsportal.php:

function prune_dir_by_days($path, $days) {
    if($filenames = array_diff(scandir($path), array('..', '.'))) {
        foreach($filenames as $file) {
            $filelastmodified = filemtime($path . $file);
            if((time() - $filelastmodified) > $days*86400)
            {
                if(is_file($path . $file)) {
                    unlink($path . $file);
                }
            }
        }
    } else {
        return false;
    }
    return true;
}

function send_admin_message($admin, $from, $subject, $message) {
    global $config_dir, $spooldir;
    if(($to = get_config_value('aliases.conf', strtolower($admin))) == false) {
        $to = strtolower($admin);
    }
    $to = trim($to);
    $from = $to;
    $database = $spooldir.'/mail.db3';
    $dbh = mail_db_open($database);
    if(!$dbh) {
        echo "Database errorn";
        return false;
    }
    $date = time();
    $msgid = '<'.md5(strtolower($to).strtolower($from).strtolower($subject).strtolower($message)).'>';
    $sql = 'INSERT OR IGNORE INTO messages(msgid, mail_from, rcpt_to, rcpt_target, date, subject, message, from_hide, to_hide, mail_viewed, rcpt_viewed) VALUES(?,?,?,?,?,?,?,?,?,?,?)';
    $stmt = $dbh->prepare($sql);
    $target = "local";
    $mail_viewed = "true";
    $rcpt_viewed = null;
    $q = $stmt->execute([$msgid, $from, $to, $target, $date, $subject, $message, null, null, false, false]);
    
    $dbh = null;
    return true;
}

-- 
Retro Guy
Technical Details
Message-ID: <cd87cb3f10d371a606b9bfa60ea37a10@rocksolidbbs.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!archive!apf9.newsdeef.eu!archive!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <cd87cb3f10d371a606b9bfa60ea37a10@rocksolidbbs.com>
Subject: Features added for InterBBS mail
Date: Wed, 9 Aug 2023 17:21:36 +0000
From: retro.guy@rocksolidbbs.com (Retro Guy)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!archive!apf9.newsdeef.eu!archive!not-for-mail
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on i2pn2.org
Newsgroups: rocksolid.nodes.announce
X-Rslight-Site: $2y$10$zX40oVIZKE6xHMrwH0LT5OiXItS/CTnUX.YZ7W61wgHJDkPtimGwO
X-Rslight-Posting-User: 7f2224730128256930309c9186f6203084896743
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
User-Agent: Rocksolid Light 0.8.5
Organization: RetroBBS
X-Face: .&YR-G(w(DZ$$,}%k=]*5*!p'=(anr"IT`wZG'2VWdfl\r)l[42u7JH`n(JUQ*e5*A|XCDf
 ?&\X&uwkl38"CYX3O8m}C8E4p'%N$2#kSTVzx{Ly|DjLT\Vk7NE}NQ(VC$Yq]i:7|z[.9iv^g>*8_B
 H0=hZt'[%)4kG|