The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

web based mail on normal port

Discussion in 'E-mail Discussions' started by Dragons Master, Mar 27, 2004.

  1. Dragons Master

    Joined:
    Mar 27, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    Heya Fellas,

    I was wondering if it's possible to have my own email viewer on my site's root, becuase on the computer I'm currently on I'm restricted to the cpanel/whm port and also the /webmail doesn't work for me here :( , so I was wondering if I could just use a php script that will run from the normal site's port (80).

    Thank you,
    - Ben Bond Pere
     
  2. oinkmedia

    oinkmedia Well-Known Member

    Joined:
    Jul 5, 2003
    Messages:
    49
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    SW London (UK)
    Try this PHP script:

    <?php
    /* proxy.php version 3.01 - A proxy script for Cpanel/WHM/Webmail
    <a href="http://scripts.brophus.com" target="_blank">http://scripts.brophus.com</a> or e-mail us at scripts@brophus.com

    Please contact us first if you wish to distribute this script;
    This header comment must remain intact at all times. Thank you

    Don't forget to ask how you can make donations!
    */

    /* To setup, you'll need to copy the next 5 lines into .htaccess
    php_value magic_quotes_gpc off
    php_flag always_populate_raw_post_data on
    RewriteEngine on
    RewriteRule !^/?proxy - [C]
    RewriteRule .* /proxy.php?port=2082 [L]

    You should change the port number (2082) in .htaccess to suit:
    CPanel port=2082
    WHM port=2086
    Webmail port=2095 (though webmail also seems to work on 2082)

    Please contact us if you have any queries. Thank you!
    */

    # you could set the default timeout and port numbers here if you want
    @$timeout = $_GET['timeout'] or $timeout = 30;
    @$port = $_GET['port'] or $port = 2082;
    # no user servicable parts below here <img src="images/smilies/wink.gif" border="0" alt="">
    $fp = @fsockopen ('127.0.0.1', $port, $errno, $errstr, $timeout)
    or die ("couldn't connect to port $port: $errstr ($errno)\n");
    $request = "{$_SERVER['REQUEST_METHOD']} {$_SERVER['REQUEST_URI']} HTTP/1.0"
    . ($nl = "\r\n");
    $headers = array_change_key_case(getallheaders(), CASE_LOWER);
    if (!(@$body = $GLOBALS['HTTP_RAW_POST_DATA'] or $body='')) {
    if ($ct = @explode('boundary=', $headers['content-type'])
    and @$boundary = $ct[1]) {
    if (@$_POST)
    foreach ($_POST as $name => $value)
    $body .= "--{$boundary}{$nl}Content-Disposition: form-data; "
    . "name=\"{$name}\"{$nl}{$nl}{$value}{$nl}";
    if (@$_FILES) {
    while (list($name, $props) = each($_FILES)) {
    $ct = $props['type'] or $ct = 'application/octet-stream';
    $body .= "--{$boundary}{$nl}Content-Disposition: form-data; "
    . "name=\"{$name}\"; filename=\"{$props['name']}\"{$nl}"
    . "Content-Type: {$ct}{$nl}{$nl}";
    if ($fd = @fopen($filename = $props['tmp_name'], 'rb')) {
    $body .= fread($fd, filesize($filename));
    fclose ($fd); }
    $body .= "$nl"; } }
    $body .= "--{$boundary}--{$nl}{$nl}"; }
    elseif (@$_POST) {
    foreach ($_POST as $name => $value)
    $vars[] = urlencode($name) . '=' . urlencode($value);
    $body .= implode('&', $vars); }
    }
    $headers['content-length'] = strlen($body);
    $headers['connection'] = 'close';
    while (list ($header, $value) = each ($headers))
    $request .= "{$header}: {$value}{$nl}";
    fputs ($fp, "$request$nl$body");
    while (!feof($fp)) {
    $line = fgets ($fp,1024);
    if ($line == "\r\n" || $line == "\n") break;
    header($line); }
    fpassthru($fp);
    ?>
     
  3. projectandrew

    projectandrew Well-Known Member

    Joined:
    Aug 27, 2003
    Messages:
    185
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    United Kingdom
  4. Dragons Master

    Joined:
    Mar 27, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Israel
    w00t w00t.. lotsa thanks there mate.. very helpful :)
     
Loading...

Share This Page