IMAP for e-newsletter

I get the following error on bounce test, even though the e-mail goes. Problem is the test section cannot read the POP3 account. Error is Call to undefined function, imap_open in ../enewsletter/enewsletter.php on line 1300 which is imap_open.

Why would you open POP3 with IMAP?

I am on Wordpress 3.4.2 MU, and current releases of your plugins. On shared hosting for GoDaddy, IMAP is not loaded, so we use POP3 instead. I have another application using POP3 and it does not have this problem (they do not use IMAP) the plugins us the core class-pop3 component built into WP.

  • aecnu

    Greetings Tazman,

    Thank you for the great question and unfortunately I have no idea why the coder chose this path but we can certainly ask him.

    I will see if I can get the lead developer in here with his invaluable insight into this plugin for his advice/advise for us concerning this imap issue.

    Though this may take a bit longer then a normal ticket, I will try to get him in here asap.

    Cheers, Joe

  • Cole

    Hey Tazman,

    e-newsletter was originally built using phpmailer 5.1

    I've been looking at changing this out, but new features have taken a priority since there seemed to be no issues with phpmailer.

    Take a look at my post here and see if that helps. I have a feeling that might work for your hosting situation too.

    https://premium.wpmudev.org/forums/topic/e-newsletter-error-when-test-connection#post-265729

    Just a clarification. The imap_open function is misleading its still accessing your pop3 server with pop3 protocols not imap.

  • Tazman

    Hi Cole,

    I see the issue is the PHP imap modual is not installed on Godaddy shared hosting (Dedicated and Virtual yes, but expensive) It will not allow the imap functions to be called at all. (undefined function, imap_open). So in these types of hosting situations you have to use the WordPress or other POP3 built in code.

    Example would be Postie uses this to read POP3 mail for posting. Rob Felty created the following to read POP3, it could be retro-fitted and setup to work in e-newsletter. (What are your thoughts?)

    /**
    *Retrieves email via POP3
    */
    function POP3MessageFetch ($server=NULL, $port=NULL, $email=NULL,
    $password=NULL, $protocol=NULL, $offset=NULL, $test=NULL,
    $deleteMessages=true) {
    require_once(ABSPATH.WPINC.DIRECTORY_SEPARATOR.'class-pop3.php');
    $pop3 = &new POP3();
    print("\nConnecting to $server:$port ($protocol)) \n");
    if (!$pop3->connect($server, $port)) {
    if (strpos($pop3->ERROR,"POP3: premature NOOP OK, NOT an RFC 1939 Compliant server") === false) {
    print("Mail Connection Time Out\n
    Common Reasons: \n
    Server Down \n
    Network Issue \n
    Port/Protocol MisMatch \n
    ");
    die("The Server Said $pop3->ERROR \n");
    }
    }

    //Check to see if there is any mail, if not die
    $msg_count = $pop3->login($email, $password);
    if ($msg_count===false) {
    $pop3->quit();
    // we should die if $msg_count is false, but the core wordpress pop3 needs
    // to be fixed before we can do that
    // die("there was a problem logging in. Please check username and password.");
    return(array());
    }

    // loop through messages
    for ($i=1; $i <= $msg_count; $i++) {
    $emails[$i] = implode ('',$pop3->get($i));
    if ($deleteMessages) {
    if( !$pop3->delete($i) ) {
    echo 'Oops '.$pop3->ERROR.'\n';
    $pop3->reset();
    exit;
    } else {
    echo "Mission complete, message $i deleted.\n";
    }
    }
    else {
    print("Not deleting messages!\n");
    }
    }
    //clean up
    $pop3->quit();
    return $emails;

  • Cole

    Well that is definitely a bummer from GoDaddy. I can see and confirm that they do not allow IMAP on their shared hosting solution. This is a large flaw for this plugin then. I wouldn't recommend GoDaddy hosting necessarily but that doesn't mean it isn't widely used by our customers.

    I'm in the last few stages of releasing a brand new version of eNewsletter. I will be trying to include a fix for this along with it. I will keep you posted.

  • Tazman

    Thank you. I quick put together code so I could eliminate this error. If you would like to use please feel free. Not pretty but got the job done.

    // Check for IMAP Module - Use IMAP if available
    if (!function_exists('imap_open')) {
    // Doesn't exist use POP3 module instead
    require_once(ABSPATH.WPINC.DIRECTORY_SEPARATOR.'class-pop3.php');
    $pop3 = &new POP3();
    print("\nConnecting to $email_host:$email_port ($protocol)) \n");
    if (!$pop3->connect($email_host, $email_port)) {
    if (strpos($pop3->ERROR,"POP3: premature NOOP OK, NOT an RFC 1939 Compliant server") === false) {
    print("Mail Connection Time Out\n
    Common Reasons: \n
    Server Down \n
    Network Issue \n
    Port/Protocol MisMatch \n
    ");
    die("The Server Said $pop3->ERROR \n");
    }
    }
    //Check to see if there is any mail, if not die
    $msg_count = $pop3->login($email_username, $email_password);
    if ($msg_count===false) {
    $pop3->quit();
    die( __( 'NO MESSAGE!', 'email-newsletter' ) );
    }
    $pop3->quit();
    die( __( 'Successfully connected!', 'email-newsletter' ) );
    }
    // IMAP starts here
    else {
    $mbox = imap_open ( '{'.$email_host.':'.$email_port.'/pop3/notls}INBOX', $email_username, $email_password ) or die( imap_last_error() );

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.