<?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 = '';
  if ( !getCurrentUserVar('UserRightEmail') ) echo $L_015;
  else
  {  
    $SenderName = getCurrentUserVar('UserName');
    $SenderEmailadress = getCurrentUserVar('UserEmailadress');
    // Mailadressen im Array speichern
      $SQL = "SELECT * FROM ".DB_PREFIX."user";
      $resultat = mysql_query($SQL);
      while ($row = mysql_fetch_array($resultat))
      {
        extract($row);
        $Empfaenger[] = $UserName." <".$UserEmailadress.">";
        $Empfaenger2[] = $UserName." (".$UserEmailadress.")";
      }
    // Content Begin
    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;
        $amountEmpfaenger = count($Empfaenger);
        for ($i=0; $i<$amountEmpfaenger; $i++)
          if ( !mail($Empfaenger[$i], $MailSubject, $MailMessage, $header) )
          {
            $Fehler++;
            echo '<span class="ERROR">'.$L_203.' ('.$Empfaenger[$i].')</span><br />';
          }
        if ( !$Fehler ) echo '<p>'.$L_055.'</p>';
      echo '<br />';
    }
    else
    {
      echo '<form method="post" action="index.php?submenu=mail&amp;page=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="ERROR">'.$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>
              <input name="submit" type="submit" value="'.$L_Button42.'" class="button" />
              <input type="reset" value="'.$L_Button38.'" class="button" />
            </td>
          </tr>
        </table>
      </form>';
    }
    // Inhalt zuende
  }
?>