Real email queue

Bug #496720 reported by Adam P
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
psiphon
Fix Committed
High
Unassigned

Bug Description

Change code to use real STMP email queue instead of SQL table queue.

From an email:

I think all our PHP code sends email via the enqueue_email function in
email_helpers.php:

function enqueue_email(

    $config,
    $email,
    $subject,
    $body,
    $lang)

{

    $query =

        "INSERT INTO email_queue (recipient_email_address, subject,

body, lang) ".

    "VALUES ( :email, :subject, :body, :lang )";

    db_query_execute($config, $query,

convert_null_array(array(":email" => $email, ":subject" => $subject,
":body" => $body, ":lang" => $lang)));
}

So to test the new method, it looks easy to change that function to
call smail_plain directly.

Looking at send_email_cron.php, I see we have some extra SQL for
invitations. What's the impact on that with this change? How
important is it that the invitation table is only updated when the
email is really sent vs. enqueued in the system?

smail_plain call:

    if (!smail_plain(

        $recordrecipient_email_address?,
        "",
        $configinvitation_sender?,
        "",
        "",
        $recordsubject?,
        $recordbody?,
        charset($recordlang?)))

    {

        echo "smail_plain failed for address:

".$recordrecipient_email_address?."\n";

    }

extra SQL:

    // Update the invitation table to reflect that the email has been sent.
    // If this email is not an invitation, this statement will have no effect.
    // (Queued email can be for purposes other than invitations --

i.e., provisioning.)

    $query =

        "UPDATE invitation ".
        "SET status = UNIX_TIMESTAMP(), email_queue_id = NULL ".
        "WHERE email_queue_id = :email_queue_id";

    if (!db_query_execute($config, $query,

convert_null_array(array(":email_queue_id" => $recordid?)), true))

    {

        @unlink($configsend_email_pid_file?);
        sql_error_cli($query, $config[sql]);

    }

Tags: category1
Revision history for this message
Adam P (adam+) wrote :

Somehow didn't get migrated from Trac. Was ticket #171

visibility: private → public
e.fryntov (e-fryntov)
tags: added: category1
Revision history for this message
Adam P (adam+) wrote :

When closing this bug, verify and close Bug #495598

Rod (rod-psiphon)
Changed in psiphon:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.