Public Member Functions | |
| dmailer_prepare ($row) | |
| dmailer_sendAdvanced ($recipRow, $tableNameChar) | |
| [Describe function...] | |
| dmailer_sendSimple ($addressList) | |
| [Describe function...] | |
| dmailer_getBoundaryParts ($cArray, $userCategories) | |
| [Describe function...] | |
| dmailer_masssend ($query_info, $table, $mid) | |
| [Describe function...] | |
| dmailer_masssend_list ($query_info, $mid) | |
| [Describe function...] | |
| shipOfMail ($mid, $recipRow, $tKey) | |
| [Describe function...] | |
| convertFields ($recipRow) | |
| [Describe function...] | |
| dmailer_setBeginEnd ($mid, $key) | |
| [Describe function...] | |
| dmailer_howManySendMails ($mid, $rtbl='') | |
| [Describe function...] | |
| dmailer_isSend ($mid, $rid, $rtbl) | |
| [Describe function...] | |
| dmailer_getSentMails ($mid, $rtbl) | |
| [Describe function...] | |
| dmailer_addToMailLog ($mid, $rid, $size, $parsetime, $html) | |
| [Describe function...] | |
| runcron () | |
| [Describe function...] | |
Public Attributes | |
| $sendPerCycle = 50 | |
| $logArray = array() | |
| $massend_id_lists = array() | |
| $flag_html = 0 | |
| $flag_plain = 0 | |
|
|
[Describe function...]
Definition at line 377 of file class.t3lib_dmailer.php. 00377 {
00378 if ($recipRow['telephone']) $recipRow['phone'] = $recipRow['telephone']; // Compensation for the fact that fe_users has the field, 'telephone' instead of 'phone'
00379 $recipRow['firstname']=trim(strtok(trim($recipRow['name']),' '));
00380 if (strlen($recipRow['firstname'])<2 || ereg('[^[:alnum:]]$',$recipRow['firstname'])) $recipRow['firstname']=$recipRow['name']; // Firstname must be more that 1 character
00381 if (!trim($recipRow['firstname'])) $recipRow['firstname']=$recipRow['email'];
00382 return $recipRow;
00383 }
|
|
||||||||||||||||||||||||
|
[Describe function...]
Definition at line 461 of file class.t3lib_dmailer.php. Referenced by dmailer_masssend(). 00461 {
00462 $temp_recip = explode('_',$rid);
00463
00464 $insertFields = array(
00465 'mid' => intval($mid),
00466 'rtbl' => $temp_recip[0],
00467 'rid' => intval($temp_recip[1]),
00468 'tstamp' => time(),
00469 'url' => '',
00470 'size' => $size,
00471 'parsetime' => $parsetime,
00472 'html_sent' => intval($html)
00473 );
00474
00475 $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_dmail_maillog', $insertFields);
00476 }
|
|
||||||||||||
|
[Describe function...]
Definition at line 241 of file class.t3lib_dmailer.php. References $key. Referenced by dmailer_sendAdvanced(). 00241 {
00242 $userCategories = intval($userCategories);
00243 reset($cArray);
00244 $returnVal='';
00245 while(list(,$cP)=each($cArray)) {
00246 $key=substr($cP[0],1);
00247 if ($key=='END' || !$key || $userCategories<0 || (intval($key) & $userCategories)>0) {
00248 $returnVal.=$cP[1];
00249 $this->mediaList.=$cP['mediaList'];
00250 }
00251 }
00252 return $returnVal;
00253 }
|
|
||||||||||||
|
[Describe function...]
Definition at line 442 of file class.t3lib_dmailer.php. 00442 {
00443 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('rid', 'sys_dmail_maillog', 'mid='.intval($mid).' AND rtbl="'.$GLOBALS['TYPO3_DB']->quoteStr($rtbl, 'sys_dmail_maillog').'" AND response_type=0');
00444 $list = array();
00445 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00446 $list[] = $row['rid'];
00447 }
00448 return implode(',', $list);
00449 }
|
|
||||||||||||
|
[Describe function...]
Definition at line 416 of file class.t3lib_dmailer.php. 00416 {
00417 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'sys_dmail_maillog', 'mid='.intval($mid).' AND response_type=0'.($rtbl ? ' AND rtbl="'.$GLOBALS['TYPO3_DB']->quoteStr($rtbl, 'sys_dmail_maillog').'"' : ''));
00418 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00419 return $row[0];
00420 }
|
|
||||||||||||||||
|
[Describe function...]
Definition at line 430 of file class.t3lib_dmailer.php. 00430 {
00431 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'sys_dmail_maillog', 'rid='.intval($rid).' AND rtbl="'.$GLOBALS['TYPO3_DB']->quoteStr($rtbl, 'sys_dmail_maillog').'" AND mid='.intval($mid).' AND response_type=0');
00432 return $GLOBALS['TYPO3_DB']->sql_num_rows($res);
00433 }
|
|
||||||||||||||||
|
[Describe function...]
Definition at line 263 of file class.t3lib_dmailer.php. References dmailer_addToMailLog(), dmailer_sendAdvanced(), numRows(), and table(). 00263 {
00264 $enableFields['tt_address']='NOT tt_address.deleted AND NOT tt_address.hidden';
00265 $enableFields['fe_users']='NOT fe_users.deleted AND NOT fe_users.disable';
00266 $tKey = substr($table,0,1);
00267 $begin=intval($this->dmailer_howManySendMails($mid,$tKey));
00268 if ($query_info[$table]) {
00269 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($table.'.*', $table, $enableFields[$table].' AND ('.$query_info[$table].')', '', 'tstamp DESC', intval($begin).','.$this->sendPerCycle); // This way, we select newest edited records first. So if any record is added or changed in between, it'll end on top and do no harm
00270 if ($GLOBALS['TYPO3_DB']->sql_error()) {
00271 die ($GLOBALS['TYPO3_DB']->sql_error());
00272 }
00273 $numRows = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
00274 $cc=0;
00275 while($recipRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00276 if (!$this->dmailer_isSend($mid,$recipRow['uid'],$tKey)) {
00277 $pt = t3lib_div::milliseconds();
00278 if ($recipRow['telephone']) $recipRow['phone'] = $recipRow['telephone']; // Compensation for the fact that fe_users has the field, 'telephone' instead of 'phone'
00279 $recipRow['firstname']=strtok(trim($recipRow['name']),' ');
00280
00281 $rC = $this->dmailer_sendAdvanced($recipRow,$tKey);
00282 $this->dmailer_addToMailLog($mid,$tKey.'_'.$recipRow['uid'],strlen($this->message),t3lib_div::milliseconds()-$pt,$rC);
00283 }
00284 $cc++;
00285 }
00286 $this->logArray[]='Sending '.$cc.' mails to table '.$table;
00287 if ($numRows < $this->sendPerCycle) return true;
00288 }
00289 return false;
00290 }
|
|
||||||||||||
|
[Describe function...]
Definition at line 299 of file class.t3lib_dmailer.php. References table(). 00299 {
00300 $enableFields['tt_address']='NOT tt_address.deleted AND NOT tt_address.hidden';
00301 $enableFields['fe_users']='NOT fe_users.deleted AND NOT fe_users.disable';
00302
00303 $c=0;
00304 $returnVal=true;
00305 if (is_array($query_info['id_lists'])) {
00306 reset($query_info['id_lists']);
00307 while(list($table,$listArr)=each($query_info['id_lists'])) {
00308 if (is_array($listArr)) {
00309 $ct=0;
00310 // FInd tKey
00311 if ($table=='tt_address' || $table=='fe_users') {
00312 $tKey = substr($table,0,1);
00313 } elseif ($table=='PLAINLIST') {
00314 $tKey='P';
00315 } else {$tKey='u';}
00316
00317 // Send mails
00318 $sendIds=$this->dmailer_getSentMails($mid,$tKey);
00319 if ($table=='PLAINLIST') {
00320 $sendIdsArr=explode(',',$sendIds);
00321 reset($listArr);
00322 while(list($kval,$recipRow)=each($listArr)) {
00323 $kval++;
00324 if (!in_array($kval,$sendIdsArr)) {
00325 if ($c>=$this->sendPerCycle) {$returnVal = false; break;} // We are NOT finished!
00326 $recipRow['uid']=$kval;
00327 $this->shipOfMail($mid,$recipRow,$tKey);
00328 $ct++;
00329 $c++;
00330 }
00331 }
00332 } else {
00333 $idList = implode(',',$listArr);
00334 if ($idList) {
00335 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($table.'.*', $table, 'uid IN ('.$idList.') AND uid NOT IN ('.($sendIds?$sendIds:0).') AND '.($enableFields[$table]?$enableFields[$table]:'1=1'), '', '', $this->sendPerCycle+1);
00336 if ($GLOBALS['TYPO3_DB']->sql_error()) {die ($GLOBALS['TYPO3_DB']->sql_error());}
00337 while($recipRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00338 if ($c>=$this->sendPerCycle) {$returnVal = false; break;} // We are NOT finished!
00339 $this->shipOfMail($mid,$recipRow,$tKey);
00340 $ct++;
00341 $c++;
00342 }
00343 }
00344 }
00345 $this->logArray[]='Sending '.$ct.' mails to table '.$table;
00346 }
00347 }
00348 }
00349 return $returnVal;
00350 }
|
|
|
Definition at line 97 of file class.t3lib_dmailer.php. References t3lib_htmlmail::useBase64(). 00097 {
00098 $sys_dmail_uid = $row['uid'];
00099 if($row["encoding"] == "base64") {
00100 $this->useBase64();
00101 }
00102 $this->theParts = unserialize($row['mailContent']);
00103 $this->messageid = $this->theParts['messageid'];
00104 $this->subject = $row['subject'];
00105 $this->from_email = $row['from_email'];
00106 $this->from_name = ($row['from_name']) ? $row['from_name'] : '';
00107 $this->replyto_email = ($row['replyto_email']) ? $row['replyto_email'] : '';
00108 $this->replyto_name = ($row['replyto_name']) ? $row['replyto_name'] : '';
00109 $this->organisation = ($row['organisation']) ? $row['organisation'] : '';
00110 $this->priority = t3lib_div::intInRange($row['priority'],1,5);
00111 $this->mailer = 'TYPO3 Direct Mail module';
00112
00113 $this->dmailer['sectionBoundary'] = '<!--DMAILER_SECTION_BOUNDARY';
00114 $this->dmailer['html_content'] = base64_decode($this->theParts['html']['content']);
00115 $this->dmailer['plain_content'] = base64_decode($this->theParts['plain']['content']);
00116 $this->dmailer['messageID'] = $this->messageid;
00117 $this->dmailer['sys_dmail_uid'] = $sys_dmail_uid;
00118 $this->dmailer['sys_dmail_rec'] = $row;
00119
00120 $this->dmailer['boundaryParts_html'] = explode($this->dmailer['sectionBoundary'], '_END-->'.$this->dmailer['html_content']);
00121 while(list($bKey,$bContent)=each($this->dmailer['boundaryParts_html'])) {
00122 $this->dmailer['boundaryParts_html'][$bKey] = explode('-->',$bContent,2);
00123 // Now, analyzing which media files are used in this part of the mail:
00124 $mediaParts = explode('cid:part',$this->dmailer['boundaryParts_html'][$bKey][1]);
00125 reset($mediaParts);
00126 next($mediaParts);
00127 while(list(,$part)=each($mediaParts)) {
00128 $this->dmailer['boundaryParts_html'][$bKey]['mediaList'].=','.strtok($part,'.');
00129 }
00130 }
00131 $this->dmailer['boundaryParts_plain'] = explode($this->dmailer['sectionBoundary'], '_END-->'.$this->dmailer['plain_content']);
00132 while(list($bKey,$bContent)=each($this->dmailer['boundaryParts_plain'])) {
00133 $this->dmailer['boundaryParts_plain'][$bKey] = explode('-->',$bContent,2);
00134 }
00135
00136 $this->flag_html = $this->theParts['html']['content'] ? 1 : 0;
00137 $this->flag_plain = $this->theParts['plain']['content'] ? 1 : 0;
00138 }
|
|
||||||||||||
|
[Describe function...]
Definition at line 147 of file class.t3lib_dmailer.php. References dmailer_getBoundaryParts(), t3lib_htmlmail::encodeMsg(), message(), t3lib_htmlmail::setContent(), t3lib_htmlmail::setHeaders(), and t3lib_htmlmail::setRecipient(). Referenced by dmailer_masssend(). 00147 {
00148 $returnCode=0;
00149 if ($recipRow['email']) {
00150 $midRidId = 'MID'.$this->dmailer['sys_dmail_uid'].'_'.$tableNameChar.$recipRow['uid'];
00151 $uniqMsgId = md5(microtime()).'_'.$midRidId;
00152 $rowFieldsArray = explode(',', 'uid,name,title,email,phone,www,address,company,city,zip,country,fax,firstname');
00153 $uppercaseFieldsArray = explode(',', 'name,firstname');
00154 $authCode = t3lib_div::stdAuthCode($recipRow['uid']);
00155 $this->mediaList='';
00156 if ($this->flag_html && $recipRow['module_sys_dmail_html']) {
00157 $tempContent_HTML = $this->dmailer_getBoundaryParts($this->dmailer['boundaryParts_html'],$recipRow['module_sys_dmail_category']);
00158 reset($rowFieldsArray);
00159 while(list(,$substField)=each($rowFieldsArray)) {
00160 $tempContent_HTML = str_replace('###USER_'.$substField.'###', $recipRow[$substField], $tempContent_HTML);
00161 }
00162 reset($uppercaseFieldsArray);
00163 while(list(,$substField)=each($uppercaseFieldsArray)) {
00164 $tempContent_HTML = str_replace('###USER_'.strtoupper($substField).'###', strtoupper($recipRow[$substField]), $tempContent_HTML);
00165 }
00166 $tempContent_HTML = str_replace('###SYS_TABLE_NAME###', $tableNameChar, $tempContent_HTML); // Put in the tablename of the userinformation
00167 $tempContent_HTML = str_replace('###SYS_MAIL_ID###', $this->dmailer['sys_dmail_uid'], $tempContent_HTML); // Put in the uid of the mail-record
00168 $tempContent_HTML = str_replace('###SYS_AUTHCODE###', $authCode, $tempContent_HTML);
00169 $tempContent_HTML = str_replace($this->dmailer['messageID'], $uniqMsgId, $tempContent_HTML); // Put in the unique message id in HTML-code
00170 $this->theParts['html']['content'] = $this->encodeMsg($tempContent_HTML);
00171 $returnCode|=1;
00172 } else $this->theParts['html']['content'] = '';
00173
00174 // Plain
00175 if ($this->flag_plain) {
00176 $tempContent_Plain = $this->dmailer_getBoundaryParts($this->dmailer['boundaryParts_plain'],$recipRow['module_sys_dmail_category']);
00177 reset($rowFieldsArray);
00178 while(list(,$substField)=each($rowFieldsArray)) {
00179 $tempContent_Plain = str_replace('###USER_'.$substField.'###', $recipRow[$substField], $tempContent_Plain);
00180 }
00181 reset($uppercaseFieldsArray);
00182 while(list(,$substField)=each($uppercaseFieldsArray)) {
00183 $tempContent_Plain = str_replace('###USER_'.strtoupper($substField).'###', strtoupper($recipRow[$substField]), $tempContent_Plain);
00184 }
00185 $tempContent_Plain = str_replace('###SYS_TABLE_NAME###', $tableNameChar, $tempContent_Plain); // Put in the tablename of the userinformation
00186 $tempContent_Plain = str_replace('###SYS_MAIL_ID###', $this->dmailer['sys_dmail_uid'], $tempContent_Plain); // Put in the uid of the mail-record
00187 $tempContent_Plain = str_replace('###SYS_AUTHCODE###', $authCode, $tempContent_Plain);
00188
00189 if (trim($this->dmailer['sys_dmail_rec']['long_link_rdct_url'])) {
00190 $tempContent_Plain = t3lib_div::substUrlsInPlainText($tempContent_Plain,$this->dmailer['sys_dmail_rec']['long_link_mode']?'all':'76',trim($this->dmailer['sys_dmail_rec']['long_link_rdct_url']));
00191 }
00192
00193 $this->theParts['plain']['content'] = $this->encodeMsg($tempContent_Plain);
00194 $returnCode|=2;
00195 } else $this->theParts['plain']['content'] = '';
00196
00197 // Set content
00198 $this->Xid = $midRidId.'-'.md5($midRidId);
00199 $this->returnPath = str_replace('###XID###',$midRidId,$this->dmailer['sys_dmail_rec']['return_path']);
00200
00201 $this->part=0;
00202 $this->setHeaders();
00203 $this->setContent();
00204 $this->setRecipient($recipRow['email']);
00205
00206 $this->message = str_replace($this->dmailer['messageID'], $uniqMsgId, $this->message); // Put in the unique message id in whole message body
00207 $this->sendtheMail();
00208 }
00209 return $returnCode;
00210 }
|
|
|
[Describe function...]
Definition at line 218 of file class.t3lib_dmailer.php. References t3lib_htmlmail::encodeMsg(), t3lib_htmlmail::setContent(), t3lib_htmlmail::setHeaders(), t3lib_htmlmail::setRecipient(), and t3lib_htmlmail::useBase64(). 00218 {
00219 $this->useBase64();
00220 if ($this->theParts['html']['content']) {
00221 $this->theParts['html']['content'] = $this->encodeMsg($this->dmailer_getBoundaryParts($this->dmailer['boundaryParts_html'],-1));
00222 } else $this->theParts['html']['content'] = '';
00223 if ($this->theParts['plain']['content']) {
00224 $this->theParts['plain']['content'] = $this->encodeMsg($this->dmailer_getBoundaryParts($this->dmailer['boundaryParts_plain'],-1));
00225 } else $this->theParts['plain']['content'] = '';
00226
00227 $this->setHeaders();
00228 $this->setContent();
00229 $this->setRecipient($addressList);
00230 $this->sendtheMail();
00231 return true;
00232 }
|
|
||||||||||||
|
[Describe function...]
Definition at line 392 of file class.t3lib_dmailer.php. References message(). 00392 {
00393 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_dmail', 'uid='.intval($mid), array('scheduled_'.$key => time()));
00394
00395 switch($key) {
00396 case 'begin':
00397 $subject = 'DMAILER mid:'.$mid.' JOB BEGIN';
00398 $message = ': '.date('d-m-y h:i:s');
00399 break;
00400 case 'end':
00401 $subject = 'DMAILER mid:'.$mid.' JOB END';
00402 $message = ': '.date('d-m-y h:i:s');
00403 break;
00404 }
00405 $this->logArray[] = $subject.': '.$message;
00406 mail($this->from_email, $subject, $message);
00407 }
|
|
|
[Describe function...]
Definition at line 483 of file class.t3lib_dmailer.php. 00483 {
00484 $pt = t3lib_div::milliseconds();
00485
00486 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_dmail', 'scheduled!=0 AND scheduled<'.time().' AND scheduled_end=0', '', 'scheduled');
00487 if ($GLOBALS['TYPO3_DB']->sql_error()) {
00488 die ($GLOBALS['TYPO3_DB']->sql_error());
00489 }
00490 $this->logArray[]='Invoked at '.date('h:i:s d-m-Y');
00491
00492 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00493 $this->logArray[]='sys_dmail record '.$row['uid'].", '".$row['subject']."' processed...";
00494 $this->dmailer_prepare($row);
00495 $query_info=unserialize($row['query_info']);
00496 if (!$row['scheduled_begin']) {$this->dmailer_setBeginEnd($row['uid'],'begin');}
00497 /*
00498 $finished = $this->dmailer_masssend($query_info,'tt_address',$row['uid']);
00499 if ($finished) {
00500 $finished = $this->dmailer_masssend($query_info,'fe_users',$row['uid']);
00501 }*/
00502 $finished = $this->dmailer_masssend_list($query_info,$row['uid']);
00503
00504 if ($finished) {$this->dmailer_setBeginEnd($row['uid'],'end');}
00505 } else {
00506 $this->logArray[]='Nothing to do.';
00507 }
00508
00509 $parsetime=t3lib_div::milliseconds()-$pt;
00510 $this->logArray[]='Ending, parsetime: '.$parsetime.' ms';;
00511 }
|
|
||||||||||||||||
|
[Describe function...]
Definition at line 360 of file class.t3lib_dmailer.php. 00360 {
00361 if (!$this->dmailer_isSend($mid,$recipRow['uid'],$tKey)) {
00362 $pt = t3lib_div::milliseconds();
00363 $recipRow=$this->convertFields($recipRow);
00364
00365 // debug('->'.$recipRow['uid'],1);
00366 $rC=$this->dmailer_sendAdvanced($recipRow,$tKey);
00367 $this->dmailer_addToMailLog($mid,$tKey.'_'.$recipRow['uid'],strlen($this->message),t3lib_div::milliseconds()-$pt,$rC);
00368 }
00369 }
|
|
|
Definition at line 90 of file class.t3lib_dmailer.php. |
|
|
Definition at line 91 of file class.t3lib_dmailer.php. |
|
|
Definition at line 88 of file class.t3lib_dmailer.php. |
|
|
Definition at line 89 of file class.t3lib_dmailer.php. |
|
|
Definition at line 87 of file class.t3lib_dmailer.php. |
1.3.8-20040913