473,320 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 1529

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 JavaScript onSubmit() function. Upon validation,...
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 situation: a computer has two access 2003 databases on...
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 vs.net code-behind?
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 some data for the job to follow, and after OK,...
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 often fond of looping through the currently loaded...
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 YearID and Year as two fields as shown below:...
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 says "Your message has been sent." How do I do...
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 include some platform invoke call. Before...
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 running into is capturing the data already entered...
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 changing. But, the form may not exist (it is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.