Jump to content

tires

Members
  • Posts

    235
  • Joined

  • Last visited

Profile Information

  • Location
    Germany

Recent Profile Visitors

3,701 profile views

tires's Achievements

Sr. Member

Sr. Member (5/6)

58

Reputation

  1. I have just realized that the module is still running with my new mailboxes. The problem was that I have several mailboxes that I retrieve. And since there is only one field for the password, this must be the same for all mailboxes ...
  2. With my new mail server, this module no longer works for me either. That's a real shame, because it's a great and helpful module. I assume that you only have to replace the flourish components with the imap_open function. Most of the code should remain untouched. I also lack the technical expertise. The AI suggests the following code: <?php /** * ProcessEmailToPage.module * Module to fetch emails from a mailbox and convert them into ProcessWire pages */ class ProcessEmailToPage extends WireData implements Module { public $moduleHash; public $emailHost; public $emailPort; public $emailPassword; public $emailType; public $forceSecure = false; public $categoryData; // Module info public static function getModuleInfo() { return array( 'title' => 'Process Email to Page', 'version' => 1, 'summary' => 'Fetches emails from a mailbox and creates pages from the messages.', 'author' => 'Your Name', 'requires' => 'ProcessWire 3.x' ); } public function init() { // Set the hash for security to ensure only authorized requests are processed $this->moduleHash = wire('config')->hash; // Example category data (JSON) $this->categoryData = '{"categories": [{"emailAddress": "your-email@example.com"}]}'; // Set connection parameters $this->emailHost = 'imap.example.com'; // Example IMAP server $this->emailPort = 993; // SSL port $this->emailPassword = 'your-password'; // Your email password $this->emailType = 'imap'; // Protocol type (imap/pop3) } public function execute() { // Process emails if the correct hash is provided if(wire('input')->get('hash') && wire('input')->get('hash') == $this->moduleHash) { // Decode category data from JSON into an object $categories = json_decode($this->categoryData); // Iterate through each email category foreach($categories as $category) { // Set up email connection $this->emailType = empty($this->emailType) ? 'imap' : strtolower($this->emailType); // Default to 'imap' $server = '{' . $this->emailHost . ':' . ($this->emailPort ? $this->emailPort : 993) . '/imap/ssl}INBOX'; // IMAP server with SSL $username = $category->emailAddress; $password = $this->emailPassword; // Connect to the mail server using imap_open $mailbox = imap_open($server, $username, $password); if (!$mailbox) { echo "Error connecting to the mail server: " . imap_last_error(); continue; } // Search for all emails (can be adjusted to 'UNSEEN' for unread emails) $emails = imap_search($mailbox, 'ALL'); if ($emails) { rsort($emails); // Sort emails with the newest first $messages = []; // Iterate through each email ID foreach($emails as $email_id) { // Fetch the email header information $overview = imap_fetch_overview($mailbox, $email_id, 0); $messages[] = $overview[0]; // Store header information // Optional: Output more header fields such as "From", "Subject", "Date" // echo "Subject: " . $overview[0]->subject . "\n"; // echo "From: " . $overview[0]->from . "\n"; // echo "Date: " . $overview[0]->date . "\n"; } // Now process the emails, for example, create a page for each email foreach ($messages as $message) { $page = $pages->add('email'); $page->title = $message->subject; $page->body = "Email from: " . $message->from . " on " . $message->date; $page->save(); } // Delete processed emails from the server foreach ($emails as $email_id) { imap_delete($mailbox, $email_id); } // Expunge to permanently remove the deleted emails imap_expunge($mailbox); } // Close the connection to the mail server after processing imap_close($mailbox); } } } }
  3. Thank you very much. I have now simply removed this hook.
  4. Please, come on! 😆 Really, i don't understand what you mean right now.
  5. Which mistake do you mean? 🤓 By the way, do I need this hook at all or does the module automatically index the edited page when it is saved?
  6. having had a lot of frustration during the year creating two shops with shopware 6, i wonder if there is an open source shop system that is as nice and simple as processwire? Do you have any experience with a system with a wide range of functions that is easy to set up and use (apart from padloper and RockCommerce)?
  7. I can't really remember why I used this module (it's been a few years). Do I really need it to find the content of the pages? You mean I should simply adapt the ready.php to, right? $wire->addHookAfter('Pages::saveReady', function($event) { $event->modules->get('SearchEngine')->indexPages($page); $page = $event->arguments(0); $event->wire('log')->save('Page saved', "Page ID: $page->id / Page Name: $page->name / Page Parents: $page->parents"); }); Thank a lot!
  8. Thank you very much for your advice! I have indeed found a hook that was apparently to blame. I can't remember exactly why I added it and what it does ... $wire->addHookAfter('Pages::saveReady', function($event) { $event->modules->get('SearchEngine')->indexPages(); $page = $event->arguments(0); $event->wire('log')->save('Page saved', "Page ID: $page->id / Page Name: $page->name / Page Parents: $page->parents"); });
  9. I have a site with about 5000 subpages and have noticed that it now takes about 10 seconds to save a page. What could be the reason for this and how can I speed up the site?
  10. Thank you for your reply. It works for me as a superuser. But the editor gets a warning message that he does not have the right to move pages (below this particular parent page). What rights do I need to give him to make this work? I have already spent half an hour unsuccessfully clicking through all the templates and role settings ...
  11. I am a little confused. As far as I remember, on my older Processwire pages, I can only move pages within the parent page (i.e. change the positions of the siblings). Now I've noticed that I can (recently?) move them across the entire page tree. How can I limit the moving of pages? I didn't get any further by setting the user rights.
  12. Thank you! Is this an official solution or some kind of hack? I can't find an info in the documentation.
  13. Hello! How can I manually deactivate or uninstall a module that no longer works after updating processwire and php? Or is it enough to simply remove the folder from the sites/modules folder? Thanks!
  14. Sorry, a made an error in thinking. There is a directory in the root with this name containing an index.html file.
×
×
  • Create New...