Changeset 532 for trunk/Common/EmailQueue.php
- Timestamp:
- Apr 24, 2013, 9:09:32 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/EmailQueue.php
r526 r532 1 1 <?php 2 2 3 class EmailQueue extends Module 4 { 5 function AddItem($To, $Subject, $Content, $From, $AttachmentFileId = '') 6 { 7 $Values = array('To' => $To, 8 'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()', 9 'From' => $From); 10 if($AttachmentFileId != '') $Values['AttachmentFile'] = $AttachmentFileId; 11 $this->Database->insert('EmailQueue', $Values); 12 } 3 class EmailQueue extends Module 4 { 5 function AddItem($To, $Subject, $Content, $From, $AttachmentFileId = '') 6 { 7 $Values = array('To' => $To, 8 'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()', 9 'From' => $From); 10 if($AttachmentFileId != '') $Values['AttachmentFile'] = $AttachmentFileId; 11 $this->Database->insert('EmailQueue', $Values); 12 } 13 14 function Process() 15 { 16 $Output = ''; 17 $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0'); 18 while($DbRow = $DbResult->fetch_assoc()) 19 { 20 $Mail = new Mail(); 21 $Mail->AddToCombined($DbRow['To']); 22 $Mail->Subject = $DbRow['Subject']; 23 $Mail->From = $DbRow['From']; 24 $Mail->AddBody(strip_tags($DbRow['Content']), 'text/plain'); 25 $Mail->AddBody($DbRow['Content'], 'text/html'); 26 if($DbRow['AttachmentFile'] != '') 27 { 28 $DbResult2 = $this->Database->select('File', '*', 'Id='.$DbRow['AttachmentFile']); 29 while($File = $DbResult2->fetch_assoc()) 30 $Mail->AttachFile($this->Config['Web']['FileRootFolder'].$File['DrivePath'], $File['MimeType']); 31 } 32 $Mail->Send(); 33 $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1)); 34 $this->ModuleManager->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']); 35 $Output .= 'To: '.$DbRow['To'].' Subject: '.$DbRow['Subject'].'<br />'; 36 } 37 return($Output); 38 } 39 } 13 40 14 function Process() 15 { 16 $Output = ''; 17 $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0'); 18 while($DbRow = $DbResult->fetch_assoc()) 19 { 20 $Mail = new Mail(); 21 $Mail->AddToCombined($DbRow['To']); 22 $Mail->Subject = $DbRow['Subject']; 23 $Mail->From = $DbRow['From']; 24 $Mail->AddBody(strip_tags($DbRow['Content']), 'text/plain'); 25 $Mail->AddBody($DbRow['Content'], 'text/html'); 26 if($DbRow['AttachmentFile'] != '') 27 { 28 $DbResult2 = $this->Database->select('File', '*', 'Id='.$DbRow['AttachmentFile']); 29 while($File = $DbResult2->fetch_assoc()) 30 $Mail->AttachFile($this->Config['Web']['FileRootFolder'].$File['DrivePath'], $File['MimeType']); 31 } 32 $Mail->Send(); 33 $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1)); 34 $this->ModuleManager->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']); 35 $Output .= 'To: '.$DbRow['To'].' Subject: '.$DbRow['Subject'].'<br />'; 36 } 37 return($Output); 38 } 39 } 40 41 ?> 41 ?>
Note:
See TracChangeset
for help on using the changeset viewer.