Changeset 66

Show
Ignore:
Timestamp:
03/08/07 15:25:19 (2 years ago)
Author:
ben
Message:

Update to mailblogger, in order to make it work with a single address rather than a catch-all IMAP account. Usernames and PINs are inserted in the subject line instead of as the To address.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mailblogger/lib.php

    r39 r66  
    1010    $CFG->mailblogger_imapusername - required 
    1111    $CFG->mailblogger_imappassword - required 
     12    $CFG->mailblogger_toaddress - required, defines the address messages are sent to 
    1213     
    1314    $CFG->mailblogger_hostname - optional, defaults to "localhost" 
     
    2021    NB: SSL unlikely to work on Windows 
    2122     
    22     $CFG->mailblogger_maildomain - optional. Used in To address detection and in user blurb 
     23    $CFG->mailblogger_maildomain - Used in To address detection and in user blurb 
    2324    $CFG->mailblogger_disablecron - optional, defaults to false; 
    2425    $CFG->mailblogger_imaprejectedmailbox - optional, if not set, rejected messages are deleted. can not be the same as $CFG->mailblogger_imapmailbox 
     
    215216         
    216217        if (is_resource($imapresource) && $uid) { 
    217              
    218218            if ($structure = imap_fetchstructure($imapresource, $uid, FT_UID)) { 
    219219                $overview = array_shift(imap_fetch_overview($imapresource, $uid, FT_UID)); 
     
    221221                $continue = false; 
    222222                // TODO - this regexp might want tuning if impure addresses are expected 
    223                 if (preg_match('/^(.+)([0-9]{4})@(.+)$/', $overview->to, $matches)) { 
     223                if (preg_match('/^(.+)([0-9]{4})$/', $overview->subject, $matches)) { 
    224224                    $username = $matches[1]; 
    225225                    $userpin = $matches[2]; 
    226                     $domain = $matches[3]; 
     226                    // $domain = $matches[3]; 
     227                    /* 
    227228                    if ($CFG->mailblogger_maildomain && $CFG->mailblogger_maildomain != $domain) { 
    228229                        mtrace('mailblogger: ignored a message due to bad To domain'); 
    229                     } elseif ($userid = user_info_username('ident', $username)) { 
     230                    } else 
     231                    */ 
     232                    if ($userid = user_info_username('ident', $username)) { 
    230233                         
    231234                        //in the absence of a general "can this username log in" function, cheat... 
     
    367370                    if ($postbody) { 
    368371                        $post = new StdClass; 
    369                         $post->title = $overview->subject; 
     372                        // $post->title = $overview->subject; 
     373                        $post->title = __gettext("External message"); 
    370374                        $post->body = $postbody; 
    371375                        if ($CFG->default_access == 'PRIVATE') { 
     
    515519        $username = user_info('username', $userid);  
    516520        if ($username && $userpin && $CFG->mailblogger_maildomain) { 
    517             $blurb .= '<br />' . __gettext("To blog by phone/mail, send your post to ") . $username . $userpin . '@' . $CFG->mailblogger_maildomain
     521            $blurb .= '<br />' . sprintf(__gettext("To blog by phone/mail, send your post to %s with %s as your subject line."), $CFG->mailblogger_toaddress, $username . $userpin . '@' . $CFG->mailblogger_maildomain)
    518522        } 
    519523