We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33337
    • 3,975 Posts
    Brilliant stuff Susan! woohoo...
      Zaigham R - MODX Professional | Skype | Email | Twitter

      Digging the interwebs for #MODX gems and bringing it to you. modx.link
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I’m planning to make it a module, and to have email sent to a specified email address when there is a submission. this way submissions can be moderated. But it could be turned into a cron job, or linked to the viewing of a specified page as well.

      Lots of configuration options come to mind. Only allow certain email addresses to post. Allow certain email addresses to post immediately, documents are inserted with "published" set to 1; the rest need moderation and "published" is set to 0. Send notification email or not; address to send such notification to.

      I"m also thinking of running with this idea to make a webmail client snippet. MODxMail. Maybe make it AJAX. Or not. But with these imap functions, you can really go to town with your site’s email.

      There are a few libraries using sockets to connect directly to your mail server if you don’t have php compiled with imap.

      @JesseR: Maybe you can try to connect to your POP server instead?
      // To connect to a POP3 server on port 110 on the local server, use:
      $mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password");
      


      http://il.php.net/manual/en/function.imap-open.php
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 14050
        • 788 Posts
        I tried connecting to the POP server instead, but still ran into trouble (RE: gmail). According to some comments to the imap_open function, the following should work for POP:

        imap_open("{pop.gmail.com:995/pop3/ssl/novalidate-cert}INBOX", $username, $pasword);


        However, I am still having trouble with imap or pop, and I have confirmed that both are enabled in my gmail settings. I google search reveals others are running into similar problems. It might just be my environment. Regardless, I can’t wait to see how this progresses.
          Jesse R.
          Consider trying something new and extraordinary.
          Illinois Wine

          Have you considered donating to MODx lately?
          Donate now. Every contribution helps.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Ah, so you want to be able to send it to your gmail, and pick it up from there. I don’t know anything at all about that. I’m presuming that this will be sent to a mail account on the server hosting the MODx installation.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 19337
            • 18 Posts
            There is a opensource tool out there that works like that, maybe you can get some ideas from there.

            http://comoblog.serialmonkey.com/comoblog/
            and
            http://sourceforge.net/projects/comoblog

            Michel
              film:projekt ------------------- autodidakten
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Try it with port 993 maybe?
              $mbox = imap_open("{pop.gmail.com:993/pop3/ssl/novalidate-cert}INBOX", $username, $pasword);


              It might be worth-while to read the user comments at the bottom of the page:
              http://il.php.net/imap_open
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 16987
                • 11 Posts
                Hey, I actually didn’t thought that there will be such a response to my wish. Thank’s.

                @sottwell:
                It would be very nice to have such a module, because I’m neither a php nor a modx crack - such a simple user with more knowledge of webdesign than of php but I’m still learning. Still I’m unable to do it myself, thats why I posted my wish here.

                Thanks again.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  I’m making progress... I actually got it to install what I emailed, but I need to figure out a different way of parsing the email messages to separate out the page title, summary and author information from the content. I don’t think it’s realistic to expect the submitter to use special delimiters; I imagine mostly it will be pasted from Word or something like that. It’s pretty easy to do this; it’s a lot harder to make it idiot proof!

                  It’s up to two articles on my site now; the first one was for actually accessing the email, this one is for parsing the messages and getting them into the database. The third article will be on making the whole thing into a configurable module.

                  When it’s done, not only will you be able to use the guest login to see the module, but you’ll be able to send email to [email protected] with a subject line containing "Submission" and see your post in a section I’ll add to the site.

                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 33033
                    • 43 Posts
                    Quote from: Jesse at Dec 06, 2007, 02:09 AM

                    I tried connecting to the POP server instead, but still ran into trouble (RE: gmail). According to some comments to the imap_open function, the following should work for POP:

                    imap_open("{pop.gmail.com:995/pop3/ssl/novalidate-cert}INBOX", $username, $pasword);


                    However, I am still having trouble with imap or pop, and I have confirmed that both are enabled in my gmail settings. I google search reveals others are running into similar problems. It might just be my environment. Regardless, I can’t wait to see how this progresses.
                    I use Google Apps for my email and got it working, so it shouldn’t be a problem to use GMail.

                    I did have a problem at first, kept getting this error:
                    imap_num_msg(): supplied argument is not a valid imap resource

                    Decided to skip that step and try to retrieve the emails and it did work. Here is the code that I used:
                    <?php
                    $uname = '[email protected]'; // mailbox login
                    $upass = 'passwd'; // mailbox password
                    $mailserver = 'imap.gmail.com'; // mail server name, or use localhost
                    $parent = 3; // the ID of the parent document for these documents
                    
                    // connect to the mail server
                    $mbox = imap_open("{imap.gmail.com:993/imap/ssl/readonly}INBOX", $uname, $upass, OP_READONLY);
                    //$total = imap_num_msg($inbox);
                    //echo $total; // if you get a number here, you're in business!!
                    // ^^didn't work - imap_num_msg(): supplied argument is not a valid imap resource
                    
                     $listing = imap_search($mbox, "TO yankeedeuce");
                    foreach($listing as $msg) {
                        $message = imap_body($mbox, $msg);
                    
                    $header = imap_header($mbox, $msg); 
                    $from = $header->from;
                    foreach ($from as $id => $object) {
                        $fromname = $object->personal; //from name
                        $fromaddress = $object->mailbox . "@" . $object->host; // from email address
                    }
                    $articletitle = $header->subject; // subject line
                    $articledate = $header->date; // date sent
                    
                        echo "<h3>$articletitle</h3> From: $fromname ($fromaddress) <br/> $articledate <p>$message</p><br />";
                    }
                    ?>



                    Great work sottwell , can’t wait to see where you take this grin
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Well, I’ve got it to install a specially formatted email into the database, but I need to figure out a different way to parse the message to pick out the page title and other metadata. I figure the user isn’t going to want to/be able to make it easy for me to parse it, I need to make it easy for him to submit it!

                      However, at the moment I have an old client who is having trouble with their mailing list. I had them set up with KoopsMailinglistX, and some people aren’t getting it. I suspect the problem is with those people’s spam detection configuration, but what can I do? Anyway, I’m working with Dada Mail on the recommendation of my hosting provider. It’s a very nice piece of work, although I think the developers are a bit on the weird side. I’ll work out a way to embed it in a module for easier access for the client once I get it all figured out.

                      Then I can get back to this. If anybody wants to take what I’ve already done and go on with it, please do.
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org