-3

Im in the process of constructing a Webmail SPA, similar to Gmail, for end users. This app will be hosted on a cPanel shared hosting (LAMP stack). The end users have no cpanel email access otherwise. My app will be their access portal for these email accounts.

If it matters, I'm preferably a node developer, with LAMP experience, so I'm open to any broad suggestions. Note, normally im just bouncing things out, using smtp. Would i just do this straight Imap? I just want to know on an architectural level what service i need to be accessing, or looking for and maybe a point in the direction of some example.

Maybe a wire-frame, a flowchart, or a sentence that can describe how I can implement it will suffice. I can find the technologies, I just need a road map.

This is a RHEL6

$ uname -a
Linux 2.6.32-604.30.3.lve1.3.63.el6.x86_64 #1 SMP Sun Sep 27 06:34:10 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

Some questions based on the only way im able to think about this problem:

What protocol normally accesses the email (user?) Would i be getting something, maybe an internal mail command access from system environment variables, or PATH maybe? Would i ping for a user list, i mean what information does the app need to connect to the mail server, and what protocol would i get that from? I think this is my hitch.

I guess the first thing, is during post, it auths, what happens after auth, what protocol, where/what will i be looking to make that decision based on, and how do i pull in the email list after? Im guessing this is just an IMAP requst. Is that all i need? e.g. php mail() or nodemailer?

Also I cant seem to come up with the proper terminology to get any meaningful google search results, I'm open to search query help as an alternative, not sure what techs I'im looking for yet.

Edit:

On some research i have found the following;

Some search terms that are finally yielding a few results

  • webmail interfacing php (or node)
  • webmail single page application node (or php)

Looks like this might be one example of a way a node app connects to an imap

If someone can help me put this into perspective, that would be great.

blamb
  • 4,220
  • 4
  • 32
  • 50
  • It's still [in the edit history](http://stackoverflow.com/revisions/42214907/2). Perhaps while adding it back you could edit out the flow-of-consciousness style into something more considered? – jonrsharpe Feb 13 '17 at 22:55
  • Or don't bother to improve it, and add more incorrect capitalisation. It's turd polishing at this point, sure, but you could still show willing. – jonrsharpe Feb 13 '17 at 23:02
  • Did you read what this site is and isn't about? The editors are us, users, and we're trying to close the question as too broad. You can ask this at Programming stack exchange site, I'm sure you will get great answers. Oh, and please post the question link here in a comment, I'd be interested in the answers myself, it's an interesting idea. – Zlatko Feb 14 '17 at 00:43
  • Sorry some things I take for granted, since I've been using stack for years.. On the other note, you mention its "interesting", makes me think I may have over-assumed that this would be a common thing. For myself it's been a mystery since i never tried it, and only became aware i could probably accomplish such a thing, in the last 5 years or so, and feel i can now pretty much do it, but this part until i actually face it, i would actually like to know more about it. So thanks for at least pointing out that I'm not asking an obvious question. I will post a back-link.. – blamb Feb 14 '17 at 02:40

1 Answers1

-1

Some answers on this:

To roll your own, webmail on a shared host, cPanel API's, curl, fopen, and 3rd party email application apis would be the starting point.

cPanel may not fully support this however they do have apis, UAPI being the most likely for some basic scenarios. https://documentation.cpanel.net/display/SDK/UAPI+Functions+-+Email%3A%3Alist_pops

However, Afterligic's WebMail Lite contains a promising looking solution, with a PHP,REST, and JavaScript API. http://www.afterlogic.org/docs/webmail-lite/integration-and-development

The PHP example to read messages looks like it might be this one here

<?php

    include_once __DIR__.'/../libraries/afterlogic/api.php';

    if (class_exists('CApi') && CApi::IsValid())
    {
        // data for logging into account
        $sEmail = 'user@domain.com';
        $sPassword = 'PassWord';

        $sFolder = 'INBOX';
        $iOffset = 0;
        $iLimit = 5;

        $oCollection = null;

        try
        {
            $oApiIntegratorManager = CApi::Manager('integrator');

            $oAccount = $oApiIntegratorManager->LoginToAccount($sEmail, $sPassword);
            if ($oAccount)
            {
                $oApiMailManager = CApi::Manager('mail');
                $oCollection =  $oApiMailManager->getMessageList($oAccount, $sFolder, $iOffset, $iLimit);

                if ($oCollection)
                {

                    echo '<b>'.$oAccount->Email.':</b><br />';
                    echo '&lt;pre&gt;';
                    echo 'Folder:   '.$sFolder."\n";
                    echo 'Count:    '.$oCollection->MessageCount."\n"; // $oCollection->MessageResultCount
                    echo 'Unread:   '.$oCollection->MessageUnseenCount."\n";
                    echo 'List:   '."\n";

                    $oCollection->ForeachList(function ($oMessage) {
                        $oFrom = $oMessage->From();
                        echo "\t".htmlentities($oMessage->Uid().') '.$oMessage->Subject().($oFrom ? ' ('.$oFrom->ToString().')' : ''))."\n";
                    });

                    echo '&lt;/pre&gt;';
                }
                else
                {
                    echo $oApiMailManager->GetLastErrorMessage();
                }
            }
            else
            {
                echo $oApiIntegratorManager->GetLastErrorMessage();
            }
        }
        catch (Exception $oException)
        {
            echo $oException->getMessage();
        }
    }
    else
    {
        echo 'AfterLogic API isn\'t available';
    }

And a Some other thoughts on rolling your own: Heres an article shedding light on how to view accounts, using php How to create an Email Account in Cpanel via PHP?

And one to list How to access list of email accounts with cPanel API?

A cpanel class was built to provide a way to create and forward, and probably serves as the best example, on a start to the solution. http://sajjadhossain.com/tag/cpanel-class/ resourced from here where lots of testing was done on this topic http://www.zubrag.com/scripts/cpanel-create-email-account.php

To forward emails, in case that's of some use to get them possibly to another temp account https://www.a2hosting.com/kb/cpanel/cpanel-mail-features/forwarding-incoming-e-mail-messages-to-a-script-file

Then there is the option for squirrel mail or the other two mail apps supported by cpanel: possibly turn one of those into a portal. Here is a way to auth to squirrel mail for e.g. http://squirrelmail.org/plugins_category.php?category_id=6

Community
  • 1
  • 1
blamb
  • 4,220
  • 4
  • 32
  • 50
  • thanks for blowing 3 points away from my life, stack community, and making me regret sharing knowledge. Can i get some downvotes on the OP so i can delete this, its pretty much bs. – blamb Mar 28 '17 at 19:27