🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: rocksolid.nodes.announce
1 messages
1 total messages Started by Retro Guy Wed, 09 Aug 2023 17:21
Features added for InterBBS mail
#447
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads