1
niktarin
sending mail from sourceforge
  • 2005/7/18 9:51

  • niktarin

  • Just popping in

  • Posts: 28

  • Since: 2003/9/21


Hi all,
I host my project on sourceforge. For quite some time now XOOPS could not send mail. Notest that when too many users could not complete the registration. So for now I have disabled the email verification. The problem still exists though. eg. when trying to retrieve a lost password. I was looking around the sf.net documentation and found this:

==========
The ability to send email from the project web servers has been stopped to curb past abuse that has occurred from the project web servers. However, we do realize that this is a valued and required feature for many projects hosted on SourceForge.net, so we have provided a method for a project to accomplish this task. At a high level, it would look like this:

1. The module of the project web service that requires the ability to send out mail would now be modified to queue the message to the project database.
2. A cron job would be configured to pull out and send the emails from the project shell server.

============
url : https://sourceforge.net/docman/display_doc.php?group_id=1&docid=4297#email

Can I edit something in XOOPS to make email sending work again? Or take any other action on this?


Thanks
Nick

2
Mithrandir
Re: sending mail from sourceforge

This won't be a two-minute fix, but here's what I would do:

Make a new module for mail queuing. In this example, I'll put it in a folder called queue and I will be using XOOPS 2.2

The module will have one table, queue_mail, with three fields: mailid, mailheader and mailbody.

It will also have a class file for managing this table:
class MailQueue extends XoopsObject {
    function 
MailQueue() {
        
$this->initVar('mailid'XOBJ_DTYPE_INT);
        
$this->initVar('mailheader'XOBJ_DTYPE_OTHER);
        
$this->initVar('mailbody'XOBJ_DTYPE_OTHER);
    }
}

class 
QueueMailHandler extends XoopsPersistableObjectHandler {
    function 
QueueMailHandler(&$db) {
        
$this->XoopsPersistableObjectHandler($db"queue_mail""MailQueue""mailid");
    }

    function 
insertMail($header$body) {
        
$obj $this->create();
        
$obj->setVar('mailheader'$header);
        
$obj->setVar('mailbody'$body);
        return 
$this->insert($obj);
    }
}


In /class/mail/xoopsmultimailer.php, make a new method like this:

function Send() {
        
$header "";
        
$body "";

        if((
count($this->to) + count($this->cc) + count($this->bcc)) < 1)
        {
            
$this->error_handler("You must provide at least one recipient email address");
            return 
false;
        }

        
// Set whether the message is multipart/alternative
        
if(!empty($this->AltBody))
            
$this->ContentType "multipart/alternative";

        
// Attach sender information & date
        
$header $this->received();
        
$header .= sprintf("Date: %s%s"$this->rfc_date(), $this->LE);
        
$header .= $this->create_header();

        if(!
$body $this->create_body())
            return 
false;

        
$mailqueue_handler =& xoops_getmodulehandler('mail''queue');
        return 
$mailqueue_handler->insertMail($header$body);
    }


Then "all" you need is to finish the module so it can be installed (and the database table created) and make a cron job on your SF.net project shell service that fetches all information from the table and sends each row as an email before deleting them from the table.
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

3
niktarin
Re: sending mail from sourceforge
  • 2005/7/22 8:14

  • niktarin

  • Just popping in

  • Posts: 28

  • Since: 2003/9/21


Thanks for the reply.

Two more things:
Is this compatible with XOOPS 2.0.x ?
What command must be used to extract the data and then delete the table?


Thanks again

4
Mithrandir
Re: sending mail from sourceforge

It is not compatible with XOOPS 2.0.x since the XoopsPersistableObjectHandler was not introduced until 2.2.

To get the data out and delete the contents of the table:

$mailqueue_handler =& xoops_getmodulehandler('mail''queue');
$mails $mailqueue_handler->getObjects();
foreach (
$mails as $mail) {
    
send($mail->getVar('mailheader'), $mail->getVar('mailbody');//REPLACE with appropriate mail sending method

    
$mailids[] = $mail->getVar('mailid');
}

$mailqueue_handler->deleteAll(new Criteria('mailid'"(".implode(','$mailids).")""IN"));


But I don't know how the project shell services work and whether you will have to use a perl script or something...
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

Login

Who's Online

391 user(s) are online (291 user(s) are browsing Support Forums)


Members: 0


Guests: 391


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits