how to get inbox messages from CPanel Webmail using PHP IMAP functions

强颜欢笑 提交于 2019-12-10 10:39:03

问题


I'm integrating auto reply mail for unread messages in my cpanel webmail/roundcube/squirrelmail. See my code below here. The problem is i'm facing imap_open function is could not connected. It's loading can't through any error/ exception too still loading. Any one guide me. I'm looking forward for your reply. Also check my code is this correct or not.


    $emailAddress = 'info@example.com'; // Full email address
    $emailPassword = 'xxxxxxxx';        // Email password
    $domainURL = 'example.com';         // Your websites domain
    $useHTTPS = false;                      

    /* BEGIN MESSAGE COUNT CODE */

    $inbox = imap_open('{'.$domainURL.':143/notls}INBOX',$emailAddress,$emailPassword) or die('Cannot connect to domain:' . imap_last_error());
    $oResult = imap_search($inbox, 'UNSEEN');

    if(empty($oResult))
        $nMsgCount = 0;
    else
        $nMsgCount = count($oResult);

    imap_close($inbox);

    echo('<p>You have '.$nMsgCount.' unread messages.</p>');

来源:https://stackoverflow.com/questions/30617992/how-to-get-inbox-messages-from-cpanel-webmail-using-php-imap-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!