<?php

$host = empty($_GET['host']) ? '' : $_GET['host'];
$user = empty($_GET['user']) ? '' : $_GET['user'];
$pw = empty($_GET['pw']) ? '' : $_GET['pw'];
if (empty($host) || empty($user) || empty($pw)) {
    echo '<p>To get mail, specify parameters (host, username and password) in url as ' . $_SERVER['REQUEST_URI'] . '?=host=hostname&user=username&pw=password</p>';
    echo '<p>Example: ' . $_SERVER['REQUEST_URI'] . '?host=mail.mydomain.com&user=name@mydomain.com&pw=1234567</p>';
} else {
    echo EmailDownload($host, '*****@*****.**', 'kny903kny903');
}
function EmailEmbeddedLinkReplace($html, $cid, $link)
{
    // In $html locate src="cid:$cid" and replace with $link.
    $cid = 'cid:' . substr($cid, 1, strlen($cid) - 2);
    $newHtml = str_replace($cid, $link, $html);
    return $newHtml;
}
function EmailConnect($host, $user, $password)
{
    $hostName = '{' . $host . ':143/novalidate-cert}INBOX';
    $inbox = imap_open($hostName, $user, $password);
    return $inbox;
}
// Based upon http://php.net/manual/en/function.imap-fetchstructure.php.
function EmailGetPart($mailbox, $emailNumber, $part, $partNo, $result)
{
    $parameter = array();
    $attachments = array();
    $plainText = '';
    $htmlText = '';
<?php

$host = empty($_GET['host']) ? '' : $_GET['host'];
$user = empty($_GET['user']) ? '' : $_GET['user'];
$pw = empty($_GET['pw']) ? '' : $_GET['pw'];
if (empty($host) || empty($user) || empty($pw)) {
    echo '<p>To get mail, specify parameters (host, username and password) in url as ' . $_SERVER['REQUEST_URI'] . '?=host=hostname&user=username&pw=password</p>';
    echo '<p>Example: ' . $_SERVER['REQUEST_URI'] . '?host=mail.mydomain.com&user=name@mydomain.com&pw=1234567</p>';
} else {
    echo EmailDownload($host, $user, $pw);
}
function EmailEmbeddedLinkReplace($html, $cid, $link)
{
    // In $html locate src="cid:$cid" and replace with $link.
    $cid = 'cid:' . substr($cid, 1, strlen($cid) - 2);
    $newHtml = str_replace($cid, $link, $html);
    return $newHtml;
}
function EmailConnect($host, $user, $password)
{
    $hostName = '{' . $host . ':143/novalidate-cert}INBOX';
    $inbox = imap_open($hostName, $user, $password);
    return $inbox;
}
function trimArray($values)
{
    $trimmed = array();
    foreach ($values as $value) {
        $trimmed[] = trim($value);
    }
    return $trimmed;