<?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
      $SQL_Befehl = "SELECT * FROM ".$prefix."user";
      $resultat = mysqli_query($db, $SQL_Befehl);
      while ($row = mysqli_fetch_array($resultat))
      {
        extract($row);
        $Empfaenger[] = $UserName." <".$UserEmailadress.">";
        $Empfaenger2[] = $UserName." (".$UserEmailadress.")";
      }
    // Inhalt hier einfügen
    if ( $submit )
    {
      $MailSubject = strip_tags($MailSubject);
      $MailMessage = strip_tags($MailMessage);
      // 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_203.' ('.$Empfaenger[$i].')</span><br />';
          }
        }
        if ( !$Fehler ) { echo '<p>'.$L_055.'</p>'; }
      echo '<br />';
    }
    else
    {
      echo '<form method="post" action="index.php?submenue=mail&amp;inhalt=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
  }
?>