Changeset 460


Ignore:
Timestamp:
Nov 5, 2012, 10:12:56 PM (12 years ago)
Author:
chronos
Message:
  • Opraveno: Odesílání emailů.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Global.php

    r459 r460  
    133133    while($DbRow = $DbResult->fetch_assoc())
    134134    {     
    135       $Mail->AddTo($DbRow['To']);
     135      $Mail->AddToCombined($DbRow['To']);
    136136      $Mail->Subject = $DbRow['Subject'];
    137137      $Mail->From = $DbRow['From'];
    138138      $Mail->AddBody(strip_tags($DbRow['Content']), 'text/plain');
    139139      $Mail->AddBody($DbRow['Content'], 'text/html');
    140       if($DbRow['AttachmentFile'] != 'NULL')
     140      if($DbRow['AttachmentFile'] != '')
    141141      {
    142         $DbResult2 = $this->Dataase->select('File', '*', 'Id='.$DbRow['AttachmentFile']);
    143         $File = $DbResult2->fetch_assoc();
    144         $Mail->AttachFile($this->Config['Web']['FileRootFolder'].$File['DrivePath'], $File['MimeType']);
     142        $DbResult2 = $this->Database->select('File', '*', 'Id='.$DbRow['AttachmentFile']);
     143        while($File = $DbResult2->fetch_assoc())
     144          $Mail->AttachFile($this->Config['Web']['FileRootFolder'].$File['DrivePath'], $File['MimeType']);
    145145      }
    146146      $Mail->Send();
  • trunk/Common/Mail.php

    r438 r460  
    4141  }
    4242
     43  function AddToCombined($Address)
     44  {
     45    $this->Recipients[] = array('Address' => $Address, 'Type' => 'SendCombined');
     46  }
     47
    4348  function AddTo($Address, $Name)
    4449  {
     
    100105    foreach($this->Recipients as $Index => $Recipient)     
    101106    {
     107      if($Recipient['Type'] == 'SendCombined')
     108      {
     109        if($Index > 0) $To .= ', ';
     110        $To .= $Recipient['Address'];
     111      } else
    102112      if($Recipient['Type'] == 'Send')
    103113      {
     
    119129   
    120130    $this->Headers['Mime-Version'] = '1.0';
    121     if(count($this->Attachments) == 0)
    122     {
    123       $this->Headers['Content-Type'] = $this->Bodies[0]['Type'].'; charset='.$this->Bodies[0]['Charset'];
    124       $this->Headers['Content-Transfer-Encoding'] = $this->ContentEncoding($this->Bodies[0]['Charset']);
    125     }
    126131   
    127132    if($this->AgentIdent != '') $this->Headers['X-Mailer'] = $this->AgentIdent;
     
    169174  private function BuildAttachment($Body)
    170175  {
    171     if(count($this->Attachments > 0))
    172     {
     176    if(count($this->Attachments) > 0)
     177    {       
    173178      $this->Headers['Content-Type'] = "multipart/mixed;\n boundary=\"PHP-mixed-".$this->Boundary."\"";
    174 
    175179      $Result = "This is a multi-part message in MIME format.\n".
    176180        "--PHP-mixed-".$this->Boundary."\n";   
     
    206210    $Result = '';
    207211    if(count($this->Bodies) > 1)
     212    {
     213      $this->Headers['Content-Type'] = 'multipart/alternative; boundary="PHP-alt-'.$this->Boundary.'"';
    208214      $Result .= 'Content-Type: multipart/alternative; boundary="PHP-alt-'.$this->Boundary.'"'.
    209215        "\n\n";
     216    } else
     217    {
     218      $this->Headers['Content-Type'] = $this->Bodies[0]['Type'].'; charset='.$this->Bodies[0]['Charset'];
     219      $this->Headers['Content-Transfer-Encoding'] = $this->ContentEncoding($this->Bodies[0]['Charset']);
     220    }
     221
    210222       
    211223    foreach($this->Bodies as $Body)
  • trunk/sql/updates/459.sql

    r459 r460  
    22
    33ALTER TABLE `EmailQueue` CHANGE `Address` `To` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL;
     4ALTER TABLE `EmailQueue` CHANGE `AttachmentFile` `AttachmentFile` INT( 11 ) NULL ;
     5UPDATE `EmailQueue` SET AttachmentFile = NULL WHERE AttachmentFile=0;
Note: See TracChangeset for help on using the changeset viewer.