Search the Community
Showing results for tags 'php email mailbox display'.
-
Retrieve And Display Newsletter Through Php Stopped Working
midway posted a topic in PHP Coding Help
Hello All, Been learning php for last 1 week only I have 2 php scripts out of which 1 has stopped working last week. 1 script binds to ldap and update a webpage which has some phone numbers. This is working fine through a cron. The other script is used to retrieve and display newsletter style emails on the same webpage (created in symfony and uses fck editor). Not sure whether you understand the issue but please feel free to ask further. I want 3 types of emails to be fetched and displayed on my homepage such as bulletin, socialnews etc. This is the affected php (/home/lib/batch/newsletter.php): #!/usr/bin/php <?php require_once(dirname(__FILE__).'/../../config/ProjectConfiguration.class.php'); $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true); sfContext::createInstance($configuration); // Remove the following lines if you don't use the database layer $databaseManager = new sfDatabaseManager($configuration); $databaseManager->loadConfiguration(); require_once 'Mail/mimeDecode.php'; require_once 'Mail/RFC822.php'; $params['include_bodies'] = true; $params['decode_bodies'] = true; $params['decode_headers'] = true; $raw_email = file_get_contents("php://stdin"); $decoder = new Mail_mimeDecode($raw_email); $structure = $decoder->decode($params); # The timestamp of the sent email. $timestamp = strtotime($structure->headers['date']); # Check if its a mime encoded message or a plain text message if (isset($structure->parts[0])) { # Mime encoded $message = $structure->parts[0]->body; } else { # Plain text $message = $structure->body; } $message = trim(strip_tags($message)); # If the message is blank then exit if (strlen($message) == 0 ) { die; } $subject = str_replace("[bulletin] ","",$structure->headers['subject']); $send_date = $structure->headers['date']; $from_address_array = Mail_RFC822::parseAddressList($structure->headers['return-path']); $from_address = trim(strtolower($from_address_array[0]->mailbox ."@". $from_address_array[0]->host)); foreach(Mail_RFC822::parseAddressList($structure->headers['to']) as $item) { $to = strtolower($item->mailbox); break; } switch ($to) { case "bulletin": $type = 1; # Bulletin break; case "seminars": $type = 2; # Seminars break; case "socialnews": $type = 3; # Seminars break; } $notice = new Notice(); $notice->setNoticeTypeId($type); $notice->setText($message); $notice->setSubject($subject); $notice->Save(); ?> # php -v PHP 5.3.15-pl0-gentoo with Suhosin-Patch (cli) (built: Sep 4 2012 11:27:33) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies # equery b php * Searching for php ... dev-lang/php-5.3.15 (/usr/lib/php5.3/bin/php) dev-lang/php-5.3.15 (/etc/php) dev-lang/php-5.3.15 (/usr/lib/php5.3/include/php) dev-php/PEAR-Archive_Tar-1.3.9 (/usr/share/php) dev-php/PEAR-Console_Getopt-1.3.1 (/usr/share/php) dev-php/PEAR-DB-1.7.14 (/usr/share/php) dev-php/PEAR-PEAR-1.9.4 (/usr/share/php) dev-php/PEAR-Structures_Graph-1.0.4 (/usr/share/php) dev-php/PEAR-XML_Util-1.2.1-r2 (/usr/share/php) dev-php/pecl-apc-3.1.9-r2 (/etc/php) dev-php/pecl-apc-3.1.9-r2 (/usr/lib/php5.3/include/php) dev-php/pecl-apc-3.1.9-r2 (/usr/share/php) # ls --full-time /etc/php total 0 drwxr-xr-x 2 root root 20 2012-07-28 18:03:38.999647793 +0100 apache2-php5 drwxr-xr-x 4 root root 47 2012-09-04 11:32:49.758142709 +0100 apache2-php5.3 drwxr-xr-x 4 root root 47 2012-09-04 11:32:49.707764554 +0100 cli-php5.3 I am using gentoo distro. Not sure whether this happened after some php update or the database table grew very big (one of the table had more than 3000 rows). I have got rid off the rows down to 3 and set the auto_increment option to 4. But that didn't help. please help if you understand the problem or ask for more details.