472,342 Members | 1,273 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,342 software developers and data experts.

form processing problem

Dormilich
8,658 Expert Mod 8TB
this is a follow-up thread to this one.
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
  1. <?php
  2. class Mail_Tabelle extends Mail_DB
  3. {
  4.     protected $description = false;
  5.     const TBL_HEAD = '
  6.     <thead>
  7.         <tr>
  8.             <th id="spalte1">Datum</th>
  9.             <th id="spalte2">Nachricht</th>
  10.         </tr>
  11.     </thead>';
  12.  
  13.     function __construct()
  14.     {
  15.         parent::load();
  16.  
  17.         if (isset($_POST['senden']))
  18.         {
  19.             $this->sendMail();
  20.         }
  21.         if (isset($_GET['desc']) and preg_match('#^\d+$#', $_GET['desc']) == 1)
  22.         {
  23.             $this->description = (int) $_GET['desc'];
  24.         }
  25.     }
  26.  
  27.     public function printTable()
  28.     {
  29.         $anzahl = count(parent::$DB_mails);
  30.         if ($anzahl == 0) return false;
  31.         echo '
  32. <table id="blog">', self::TBL_HEAD, '
  33.     <tbody>';
  34.         for ($i=0; $i<$anzahl; ++$i)
  35.         {
  36.             $desc = ($this->description === $i) ? true : $i;
  37.             parent::$DB_mails[$i]->printTableRow($desc); 
  38.         }
  39.         echo '
  40.     </tbody>
  41. </table>
  42. ';
  43.     }
  44.  
  45.     protected function sendMail()
  46.     {
  47.         $text = $_POST["NLG"];
  48.         $betreff = $_POST["betreff"];
  49.         if (!$text or !$betreff) return false;
  50.         $adr = $this->prepareMail();
  51.         $msg = "[...]";
  52.         $RS = new Mail_Verteiler($msg, $betreff); // problem is HERE
  53.         $RS->setList($adr);
  54.         $RS->sendMails();
  55.         $this->saveMail();
  56.     }
  57. }
  58. ?>
I suspect something with the loading isn't going right, because it doesn't matter if I uncomment the parent constructor (line 11) or not.

can anyone give me an idea how to get some clues where the problem's cause is?
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once LIB_DIR . "Swift/Plugin/Decorator.php";
  3.  
  4. class Mail_Verteiler extends KBL_Mail
  5. {
  6.     protected $to = NULL;
  7.     protected $replace = array();
  8.  
  9.     function __construct($msg, $subj)
  10.     {
  11.         parent::__construct($msg, $subj);
  12.     }
  13.  
  14.     public function setList($empfanger)
  15.     {
  16.         if (!is_array($empfanger)) return false;
  17.         if (!($this->to instanceof Swift_RecipientList))
  18.         {
  19.             $this->to = new Swift_RecipientList;
  20.         }
  21.         foreach ($empfanger as $person)
  22.         {
  23.             $Name = ($person['Name']) ? $person['Name'] : 'Leser';
  24.             $this->to->addTo($person['Email']);
  25.             $this->replace[] = array('{name}' => $Name, '{UID}' => $person['UID']);
  26.         }
  27.         return true;
  28.     }
  29.  
  30.     public function sendMails($from = 'email@host.tld')
  31.     {
  32.         if (!($this->to instanceof Swift_RecipientList)) 
  33.         {
  34.             $this->sent = false;
  35.             return false;
  36.         }
  37.         $this->mail->attachPlugin(new Swift_Plugin_Decorator($this->replace), "decorator");
  38.         return $this->sendTo($this->to, $from);
  39.     }
  40. }
  41. ?>
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once LIB_DIR . "Swift.php";
  3. require_once LIB_DIR . "Swift/Connection/SMTP.php";
  4. require_once CONF_DIR . "conf.mail.php";
  5.  
  6. /**
  7.  * a little wrapper around Swift_Mail for sending error reports.
  8.  * only basic email sending is intended, so for HTML form results
  9.  * use Swift directly.
  10.  */
  11. class KBL_Mail
  12. {
  13.     /**
  14.      * @var (object) $mail      Swift Mail (root) class
  15.      * @var (bool) $sent        success of sending the email
  16.      * @var (string) $subject   email subject
  17.      * @var (string) $message   email message
  18.      */
  19.     protected $mail = NULL;
  20.     protected $sent = false;
  21.     public    $subject;
  22.     public    $message;
  23.  
  24.     /**
  25.      * establish the connection to the SMTP server
  26.      * load subject & message
  27.      */
  28.     function __construct($message = '', $subject = 'Fehlerbericht')
  29.     {
  30.         # connect to the mail server
  31.         $smtp = new Swift_Connection_SMTP(KBL_MAIL_SMTP_STD, 587, Swift_Connection_SMTP::ENC_OFF);
  32.         $smtp->setUsername(KBL_MAIL_USER);
  33.         $smtp->setPassword(KBL_MAIL_PASS);
  34.  
  35.         # create swiftmailer class
  36.         $this->mail = new Swift($smtp);
  37.         $this->subject = $subject;
  38.         $this->message = $message;
  39.     }
  40.  
  41.     function __destruct()
  42.     {
  43.         $this->mail->disconnect();
  44.     }
  45.  
  46.     /**
  47.      * send email
  48.      *
  49.      * @param (string) $to       recipient (To:)
  50.      * @param (string) $from     sender (From:)
  51.      * @return (void)
  52.      */
  53.     public function sendTo($to = KBL_MAILTO_ADMIN, $from = 'email@host.tld')
  54.     {
  55.         $swift_msg = new Swift_Message($this->subject, $this->message);
  56.         $swift_msg->headers->setLanguage("de");
  57.         $this->sent = $this->mail->send($swift_msg, $to, $from);
  58.         return $this->sent;
  59.     }
  60. }
  61. ?>
Feb 15 '09 #1
0 1453

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: dmcconkey | last post by:
Hi folks, I have a client with four websites. Each site has a contact form that is identical. They all have "required" fields validated through a...
13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the...
5
by: Scott | last post by:
How can I tell a form to submit itself in the code-behind in vs.net? In other words, in javascript I can do blah.submit() - how do I do this in...
12
by: Ger | last post by:
My dialogue form (sometimes partly, sometimes as a whole) remains visible during a fairly long processing job. The dialogue asks the user to enter...
7
by: gerryLowry::Ability Business Computer Services {KC | last post by:
"Getting Back Your Visual Basic 6.0 Goodies" by Billy Hollis, 2003-5-14, states: "Getting a Forms Collection Visual Basic 6.0 developers are...
15
by: Jack | last post by:
Hi, I have a asp form where one element is a list box which lists four years starting from 2004. This list is drawn from a database table which has...
13
by: deko | last post by:
I have a basic feedback form with a submit button. After the "send" button is clicked, I want the user to be redirected to a different page that...
2
by: AJang | last post by:
My windows form "Form1" has one Button "button1" and one TextBox "textBox1". When I click button1, it do a job for each file in a directory. The job...
4
by: Greg Scharlemann | last post by:
I'm trying to setup a dyamic dropdown list that displays a number of text fields based on the selected number in the dropdown. The problem I am...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.