http://bytes.com/topic/html-css/answ...tted-sometimes
I figured out that the mail sending class triggers the described error. unfortunately, no error message is given by the system.
Expand|Select|Wrap|Line Numbers
- <?php
- class Mail_Tabelle extends Mail_DB
- {
- protected $description = false;
- const TBL_HEAD = '
- <thead>
- <tr>
- <th id="spalte1">Datum</th>
- <th id="spalte2">Nachricht</th>
- </tr>
- </thead>';
- function __construct()
- {
- parent::load();
- if (isset($_POST['senden']))
- {
- $this->sendMail();
- }
- if (isset($_GET['desc']) and preg_match('#^\d+$#', $_GET['desc']) == 1)
- {
- $this->description = (int) $_GET['desc'];
- }
- }
- public function printTable()
- {
- $anzahl = count(parent::$DB_mails);
- if ($anzahl == 0) return false;
- echo '
- <table id="blog">', self::TBL_HEAD, '
- <tbody>';
- for ($i=0; $i<$anzahl; ++$i)
- {
- $desc = ($this->description === $i) ? true : $i;
- parent::$DB_mails[$i]->printTableRow($desc);
- }
- echo '
- </tbody>
- </table>
- ';
- }
- protected function sendMail()
- {
- $text = $_POST["NLG"];
- $betreff = $_POST["betreff"];
- if (!$text or !$betreff) return false;
- $adr = $this->prepareMail();
- $msg = "[...]";
- $RS = new Mail_Verteiler($msg, $betreff); // problem is HERE
- $RS->setList($adr);
- $RS->sendMails();
- $this->saveMail();
- }
- }
- ?>
can anyone give me an idea how to get some clues where the problem's cause is?
Expand|Select|Wrap|Line Numbers
- <?php
- require_once LIB_DIR . "Swift/Plugin/Decorator.php";
- class Mail_Verteiler extends KBL_Mail
- {
- protected $to = NULL;
- protected $replace = array();
- function __construct($msg, $subj)
- {
- parent::__construct($msg, $subj);
- }
- public function setList($empfanger)
- {
- if (!is_array($empfanger)) return false;
- if (!($this->to instanceof Swift_RecipientList))
- {
- $this->to = new Swift_RecipientList;
- }
- foreach ($empfanger as $person)
- {
- $Name = ($person['Name']) ? $person['Name'] : 'Leser';
- $this->to->addTo($person['Email']);
- $this->replace[] = array('{name}' => $Name, '{UID}' => $person['UID']);
- }
- return true;
- }
- public function sendMails($from = 'email@host.tld')
- {
- if (!($this->to instanceof Swift_RecipientList))
- {
- $this->sent = false;
- return false;
- }
- $this->mail->attachPlugin(new Swift_Plugin_Decorator($this->replace), "decorator");
- return $this->sendTo($this->to, $from);
- }
- }
- ?>
Expand|Select|Wrap|Line Numbers
- <?php
- require_once LIB_DIR . "Swift.php";
- require_once LIB_DIR . "Swift/Connection/SMTP.php";
- require_once CONF_DIR . "conf.mail.php";
- /**
- * a little wrapper around Swift_Mail for sending error reports.
- * only basic email sending is intended, so for HTML form results
- * use Swift directly.
- */
- class KBL_Mail
- {
- /**
- * @var (object) $mail Swift Mail (root) class
- * @var (bool) $sent success of sending the email
- * @var (string) $subject email subject
- * @var (string) $message email message
- */
- protected $mail = NULL;
- protected $sent = false;
- public $subject;
- public $message;
- /**
- * establish the connection to the SMTP server
- * load subject & message
- */
- function __construct($message = '', $subject = 'Fehlerbericht')
- {
- # connect to the mail server
- $smtp = new Swift_Connection_SMTP(KBL_MAIL_SMTP_STD, 587, Swift_Connection_SMTP::ENC_OFF);
- $smtp->setUsername(KBL_MAIL_USER);
- $smtp->setPassword(KBL_MAIL_PASS);
- # create swiftmailer class
- $this->mail = new Swift($smtp);
- $this->subject = $subject;
- $this->message = $message;
- }
- function __destruct()
- {
- $this->mail->disconnect();
- }
- /**
- * send email
- *
- * @param (string) $to recipient (To:)
- * @param (string) $from sender (From:)
- * @return (void)
- */
- public function sendTo($to = KBL_MAILTO_ADMIN, $from = 'email@host.tld')
- {
- $swift_msg = new Swift_Message($this->subject, $this->message);
- $swift_msg->headers->setLanguage("de");
- $this->sent = $this->mail->send($swift_msg, $to, $from);
- return $this->sent;
- }
- }
- ?>