dcsimg
June 20, 2018
Hot Topics:

Enhancing your Webmail program

  • May 25, 1999
  • By Bjxrn Borud
  • Send Email »
  • More Articles »

imapfuncs.phl

\n";
    print "
\n"; print ""; print ""; print "\n"; $i = 1; $bgcolor = $M_COLOR_EVEN; print "\n"; print " \n"; print "\n"; if ($mailboxes) { while (list($dummy, $box) = each($mailboxes)) { $bgcolor = ($i%2 == 0)?$M_COLOR_EVEN:$M_COLOR_ODD; print "\n"; print " \n"; print "\n"; $i++; } } print "
Folder name
Default inbox
$box
\n"; print ""; print "\n"; print "\n"; } function m_create_mailbox ($new = '') { global $MBOX, $M_REALM; global $PHP_AUTH_USER, $PHP_AUTH_PW; if (! $MBOX) { m_login("INBOX"); } if ($new == "") { return false; } $name = m_mailbox_name($new); $result = imap_createmailbox($MBOX, $name); return $result; } function m_login ($mailbox = '') { global $MBOX, $M_REALM; global $PHP_AUTH_USER, $PHP_AUTH_PW; if ($MBOX) { return true; } if (! $PHP_AUTH_USER) { m_reject($M_REALM); } $MBOX = @imap_open(m_mailbox_name($mailbox), $PHP_AUTH_USER, $PHP_AUTH_PW); if (! $MBOX) { m_reject($M_REALM); } return true; } function m_list($mailbox = '') { global $MBOX, $PHP_SELF; global $M_COLOR_ODD, $M_COLOR_EVEN, $M_COLOR_HEAD, $M_COLOR_BG; /* if not logged into server, do so */ if (! $MBOX) { if (! m_login($mailbox)) { return false; } } $num = imap_num_msg($MBOX); print "
\n"; print "
\n"; print ""; print ""; print "\n"; for ($i=1; $i < ($num+1); $i++) { $head = imap_header($MBOX, $i, 50, 50, 0); $from = $head->fetchfrom; $subj = $head->fetchsubject; $date = m_date_format($head->date); $bgcolor = ($i%2 == 0)?$M_COLOR_EVEN:$M_COLOR_ODD; print "\n"; print " \n"; print " "; print ""; print "\n"; print "\n"; } if ($num <= 0) { print "\n"; } print "\n"; print "
 FromSubjectDate
$from$subj$date

"; print "No messages in mailbox"; print "

"; print "\n"; print ""; print ""; print ""; print "\n"; print ""; print ""; $mailboxes = m_list_mailboxes(); if (count($mailboxes) > 0) { print "\n"; } print "
\n"; print "
\n"; return true; } function m_display($msgno, $mailbox = '') { global $MBOX, $M_COLOR_HEAD, $M_COLOR_BG; global $PHP_SELF; if (! $MBOX) { if (! m_login($mailbox)) { return false; } } $struc = imap_fetchstructure($MBOX, $msgno); if (! $struc) { return false; } $head = imap_header($MBOX, $msgno, 50, 50, 0); $from = $head->fromaddress; $subj = $head->subject; $date = $head->date; $body = htmlentities(imap_body($MBOX, $msgno)); print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
Message #$msgno: $from / $subj
\n";
  print "From: $from\n";
  print "Subject: $subj\n";
  print "Date: $date\n";
  print "
\n"; print "$body\n"; print "
"; print "
"; print "\n"; print "\n"; print "\n"; print ""; print ""; print "     "; print "
\n"; print "
\n"; return true; } function m_delete ($msgno, $mailbox='') { global $MBOX; if (is_array($msgno)) { while (list($dummy, $num) = each($msgno)) { imap_delete($MBOX, $num); } imap_expunge($MBOX); } else { return false; } return true; } function m_compose ($msgno='', $mailbox='') { global $MBOX, $M_COLOR_HEAD, $M_COLOR_BG; global $PHP_SELF, $PHP_AUTH_USER, $M_MAILSERVER; if ($msgno != '') { $head = imap_header($MBOX, $msgno, 150, 150, 0); $to = $head->fromaddress; $subject = "Re: " . $head->subject; $body = "$to wrote:\n"; $body .= ereg_replace("\n","\n>", "\n" . imap_body($MBOX, $msgno)); } else { $to = ""; $subject = ""; $body = ""; } print "
\n"; print "\n"; print "\n"; print ""; print "\n"; print ""; print "\n"; print "\n"; print ""; print "
To:
Subject:
"; print "\n"; print "
"; print ""; print ""; print ""; print "
\n"; print "
\n"; } function m_send ($to, $subject, $body) { global $PHP_AUTH_USER, $M_MAILSERVER, $M_SYSNAME; if ($PHP_AUTH_USER && $M_MAILSERVER && $to && $body) { $headers = "From: $PHP_AUTH_USER@$M_MAILSERVER\n"; $headers .= "Reply-to: $PHP_AUTH_USER@$M_MAILSERVER\n"; $headers .= "Content-Type: text/plain; charset=iso-8859-1\n"; $headers .= "Content-Transfer-Encoding: 8bit\n"; $headers .= "X-Mailer: $M_SYSNAME/" . phpversion() . "\n"; return mail($to, $subject, $body, $headers); } return false; } function m_date_format($datestr) { if (ereg("([[:digit:]]{1,2})[[:space:]]+([[:alpha:]]{3})[[:space:]]+([[:digit:]]{4})", $datestr, $regs)) { return $regs[0]; } return $datestr; } function m_mailbox_name ($mbx) { global $M_MBOX, $M_PREFIX; /* no mailbox specified means we map it to the inbox */ if ($mbx == "") { return $M_MBOX . "INBOX"; } /* replace some special chars */ $mbx = ereg_replace("[^[:alnum:]]", "_", $mbx); return $M_MBOX . $M_PREFIX . $mbx; } function m_strip_mbox_name ($mbx) { global $M_PREFIX; ereg("$M_PREFIX(.*)$", $mbx, $regs); return $regs[1]; } function m_reject($dom) { Header("HTTP/1.0 401 Unauthorized"); Header("WWW-authenticate: basic realm=\"$dom\""); print "Access denied\n"; exit; } /* make sure there is NO trailing space here!!! */ ?>





Page 6 of 7



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.

Sitemap

×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date