<?php
/*
    CREATIVE COMMONS - Attribution-No Derivative Works 3.0 Germany:
    - You may not alter, transform, or build upon this work.
    - Dieses Werk darf nicht bearbeitet oder in anderer Weise verändert werden.
*/
  if ( !isset($submit) ) $submit = '';
  echo '<p class="Headline">'.$L_Headline03.'</p>';
  if ( !getCurrentUserVar('UserRightEmail') ) { echo $L_015; }
  else
  {  
    $SenderName = getCurrentUserVar('UserName');
    $SenderEmailadress = getCurrentUserVar('UserEmailadress');
    // Mailadressen im Array speichern
      $SQLQuery = "SELECT * FROM ".$prefix."user";
      $Result = mysqli_query($db, $SQLQuery);
      while ($row = mysqli_fetch_array($Result))
      {
        extract($row);
        $Empfaenger[] = $UserName." <".$UserEmailadress.">";
        $Empfaenger2[] = $UserName." (".$UserEmailadress.")";
      }
    // Inhalt hier einfügen
    if ( $submit )
    {
      $MailSubject = strip_tags($MailSubject);
      $MailMessage = strip_tags($MailMessage);
      $MailMessage = wordwrap($MailMessage, 70, "\n"); // Bug fix v1.2.83_059
      // Header definieren
        $optheader[] = "From: ".$SenderName." <".$SenderEmailadress.">";
        $optheader[] = "Content-Type: text/plain; Charset=utf-8";
        $header = implode("\n", $optheader);
      // Mail versenden
        $Fehler = 0;
        for ($i=0; $i<count($Empfaenger); $i++)
        {
          if ( !mail($Empfaenger[$i], $MailSubject, $MailMessage, $header) )
          {
            $Fehler++;
            echo '<span class="ErrorMessage">'.$L_ERROR_Email_could_not_be_sent.' ('.$Empfaenger[$i].')</span><br />';
          }
        }
        if ( !$Fehler ) { echo '<p>'.$L_055.'</p>'; }
      echo '<br />';
    }
    else
    {
      echo '<form method="post" action="index.php?submenue=mail&amp;content=mail" accept-charset="UTF-8">
              <p>'.$L_021.'</p>
              <table summary="Mailing">
                <tr>
                  <td></td>
                  <td></td>
                </tr>
                <tr>
                  <td>'.$L_022.'</td>
                  <td><input class="DisabledTextarea" type="text" name="MailFrom" maxlength="50" value="'.$SenderName.' ('.$SenderEmailadress.')" readonly="readonly" /></td>
                </tr>
                <tr>
                  <td>'.$L_024.'</td>
                  <td>';
      $anzahlMailadresse = count($Empfaenger2);
      if ($anzahlMailadresse==0) { echo '<div class="ErrorMessage">'.$L_059.'</div>';};
      for ($i=0;$i<$anzahlMailadresse;$i++)
      {
        echo '<input class="DisabledTextarea" type="text" name="MailBCC" maxlength="40" value="'.$Empfaenger2[$i].'" readonly="readonly" /><br />';
      }
      echo '</td>
          </tr>
          <tr>
            <td>'.$L_025.'</td>
            <td><input type="text" name="MailSubject" maxlength="50" value="" /></td>
          </tr>
          <tr>
            <td>'.$L_026.'</td>
            <td><textarea name="MailMessage" rows="6" cols=""></textarea></td>
          </tr>
          <tr>
            <td></td>
            <td><br />
              <input name="submit" type="submit" value="'.$L_Button42.'" class="button" />
              <input type="reset" value="'.$L_Button38.'" class="button" />
            </td>
          </tr>
        </table>
      </form>';
    }
    // Inhalt zuende
  }
?>