Connect POP3 mailbox using PHP

Use the following process to connect to the inbox of a specific account:

$emailbox = imap_open(“{mail.domainname:110/pop3}INBOX”, ‘username’, ‘password’);

$emailinfo = imap_check($emailbox);

$nummessages = $emailinfo->Nmsgs;

if (stripos(imap_body($emailbox, $emailinfo->Nmsgs), ‘trigger phrase’) !== false) {

// Trigger detected



imap_open – returns a stream handler, it creates a connection to the mail server and returns it’s handler (the parameters are pretty obvious, the first one is the server data: host, port,protocol and folder, the second is the mailbox username and the third one is the password)

imap_check – returns mailbox data, this object’s Nmsgs property returns the number of new messages

imap_body – return the message with the number from the second parameter

imap_close – closes the stream