Design of Intranet Mail System
Design of Intranet Mail System
SYSTEM
A
Project report
Submitted in Partial Fulfillment of the
Requirements of the Award of Degree of
Bachelor of Technology
of
National Institute of Technology Calicut
By
This is to certify that this document entitled “Design of an Intranet Mail Client
System”, is a bonafide record of the project work done by “ Mr. Biswajoy Biswas”
( Y2.240 ) and in the year 2005-2006, under our supervision and guidance. This report
of Technology, Calicut, in partial fulfillment of the requirements for the award of the
Table of Content
ACKNOWLEDGEMENT
CERTIFICATE
3. INSTALLING PACKAGES..........................................................................................20
3.1. Installing the Debian Sid – Linux Platform................................................................21
3.2. Configuring the Sendmail...........................................................................................21
3.3. Configuring SASL......................................................................................................22
4. IMPLEMENTATION....................................................................................................24
5. IMPLEMENTING THE USER FUNCTIONALITIES ................................................29
6. PSEUDOCODE FOR THE COMPONENTS...............................................................33
7. RESULTS......................................................................................................................37
Table of Figures
…………………….…………….17
Figure 5 DEMONSTRATION OF ADMINISTRATOR COMMANDS…………….24
Figure 6 USERS DATA STORAGE 1……………………………………………….25
Figure 7 USERS DATA STORAGE 2……………………………………………….26
Figure 8:SAMPLE VIEW OF MAILBOX…………………………………………...34
ABSTRACT
The aim of the project was to develop an Intranet web based mail client system
connecting to a Linux server running a mail server and with Apache as the web server.
The aim was to implement the necessary functionalities to the users such as receiving and
organizing mails through IMAP and Sending mails using send mail. All these are
provided with the graphical interface so that the users can do their desired work
smoothly. Apart from that, the administrator can create and delete user accounts through
the Cyrus Server.
The system starts with the welcome page prompting the user to establish
his authentication. He is allowed to see his mailboxes, read mails and send mails to the
other users only after his/her account is verified.
1. INTRODUCTION
This Chapter outlines the aims of the project and motivation behind its implementation.
This project aims at developing a web based mail client that serves
the users to send and receive mails through Sendmail as the (MTA) message transport
agent and IMAP as the message delivery agent.
The existing users are needed to authenticate their identity and then
they are permitted to check their mails in their mailbox. Also they can send mails,
organize mails across the folders and can delete the unnecessary mails form their
mailboxes. A good user interface has been provided for performing all these tasks easily.
Login Page:
There should be a login page for the existing user where the
username and password are verified and then if he is a valid user, he is allowed for
further advancements.
Inbox:
The logged in users should be able to see the lists of new mails as
well as the existing ones.
Compose Mail:
User should be able to compose mails and send them to the other
users.
Reply/Forward/Delete:
The user should be able to reply to mails, forward mails and also
delete mails from his mailboxes. The deleted mails should be moved to the Thrash
mailbox.
Organize Mails:
The user should be able to organize his mails into the existing
folders.
Attach files:
The user should be able to attach files to the mails and send them
to the desired users.
Save as Draft:
The user should be able to save the incomplete mails in the Draft
mailbox and these can be completed later and can be sent to others.
Trash mailbox:
This mailbox keeps a record of the deleted mails from the other
mailboxes such as Inbox, Sent, and Draft. If further mails are deleted from this, the mails
should be permanently deleted from the users’ accounts.
Security:
Only the administrator should be able to maintain the users’
accounts such as creating new users and deleting the existing users’ accounts.
Database:
Portability:
The web client system should work in both the windows and the
Linux platform.
The protocol to be used is IMAP which serves as the Message Delivery Agent.
\Recent Message is "recently" arrived in this mailbox. This session is the first
session to have been notified about this message; subsequent sessions will not see
\Recent set for this message. This flag can not be altered by the client.
The users will attempt to access their emails via insecure networks,
Compromise their password, and thus give malicious users a point of entry to the system.
As the number of users grows, the risk increases, as there are now more potential access
points to the system. So IMAP server that allows creating email-only users who are
totally separate from the local system ("UNIX") account database seems to be a more
secure answer to the problem mentioned above.
1.5. MOTIVATION
.
2. DESIGN
This chapter describes the design decisions made to meet the aims
that are specified in the specifications required. This chapter will also bring in some of
the ideas and research outlined in the previous chapter.
Figure 1
• Here the browser clients have an email account. The authentication of the users is
verified by the Cyrus IMAP server and the valid users are allowed to read their
mailboxes.
• They can send mails with the Sendmail as the MTA. Thus the job of Sendmail is
to transport mails and is not concerned about the messages inside the body.
• The incoming mails are sent into the respective mailbox of the users.
• Users can read mails from their mailboxes. They can send mails and can delete
the unnecessary ones.
• The user details are stored in the MYSQL Database which can retrieve them as
needed.
Sendmail: It is one of the most popular UNIX based implementation of SMTP (Sendmail
Transfer Protocol).
Cyrus IMAP: Cyrus IMAP (Internet Message Access Protocol) server provides access to
personal mail through the IMAP protocol. It uses a pseudo database format. This
provides email only users who are totally separate from the local UNIX account database.
The mailbox database is stored in parts of the file system that are private to the Cyrus
IMAP.
This is the format of the table and the required fields used for
maintaining the personal data of the users and thus enable the users search for the
required mail ids.
Before installing packages, make sure your APT sources are up to date:
Enable encrypted connections using SSL and TLS by adding support for the STARTTLS
SMTP command. Append this line to the end of /etc/mail/sendmail.mc:
Sendmail is configured to use the Cyrus delivery agent, required for mail delivery to a
Cyrus mailbox:
The following changes are made, adding the appropriate entries where necessary:
pwcheck_method: saslauthd
auto_transition: false
To make the saslauthd to start at the time of booting, the comments are removed from
START=yes
MECHANISMS="sasldb"
sasl_pwcheck_method: saslauthd
Note that when an account is created, SASL will save the secure passwords.
sasl_auto_transition: no
tls_cert_file: /etc/ssl/certs/cyrus-global.pem
tls_key_file: /etc/ssl/certs/cyrus-global.pem
Enable secure IMAP by uncommenting the line starting with "imaps" under the
"SERVICES" section (remove the preceding #). Disable the POP services, and the
regular IMAP service "imap". Depending on the server load, you may need to increase
the -U and prefork= options.
.For added security, it is best to restrict file permissions on your certificates. At the very
least, change the file owner to "cyrus" and tighten security permissions:
root@server~# chown cyrus /etc/ssl/certs/cyrus-global.pem
root@server~# chmod o-rw /etc/ssl/certs/cyrus-global.pem
Restart Cyrus:
root@server~# /etc/init.d/cyrus21 restart
Thus the above packages are installed. After the installations are
over, the Cyrus administrator’s password should be set through executing the following
command.
Once the password is set, the administrator can create the users
accounts, delete the existing ones and so on. The following chapter describes the
administrators functionalities.
4. IMPLEMENTATION
4.1 Implementing the Administrator Functionalities
• Create Accounts
New User accounts can be created by the Cyrus administrator
Cm user.account_id;
Here account_id is the name of the new user that a mailbox has
been created.The Cyrus on default provides four mailboxes
INBOX, INBOX.Sent, INBOX.Draft and INBOX.Trash.
After creating the mailbox for the new user, the password is setup
as follows.
• Delete Accounts
• Viewing mailboxes
The administrator can keep track of the available users and can
view his mailboxes and nails residing in the mailboxes. He should
execute the following command.
5.1.1 CAPABILITY
5.2 LOGOUT
The LOGOUT command informs the server that the client is done
with the connection. The server MUST send a BYE untagged response before the
(tagged) OK response, and then close the network connection.
5.3 AUTHENTICATE
5.4. SELECT
FLAGS Defined flags in the mailbox. See the description of the FLAGS response for
more detail.
<n> RECENT - The number of messages with the \Recent flag set.
5.5 CLOSE
5.6 EXPUNGE
BODY[<section>]<<partial>>
The text of a particular body section. The section specification is a set of zero or more
part specifiers delimited by periods. A part specifier is either a part number or one of the
following:
HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, MIME, and TEXT.
An empty section specification refers to the entire message, including the header.
Every message has at least one part number. Non-[MIME-IMB] messages, and non-
multipart [MIME-IMB] messages with no encapsulated message, only have a part 1.
Multipart messages are assigned consecutive part numbers, as they occur in the message.
If a particular part is of type message or multipart, its parts MUST be indicated by a
period followed by the part number within that nested multipart part.
5.8 STORE
Arguments: message set, message data item name value for message data item
5.9 COPY
The COPY command copies the specified message(s) to the end of the specified
destination mailbox. The flags and internal date of the message(s) should be preserved in
the copy.
5.10 UID
The UID command has two forms. In the first form, it takes as its arguments a COPY,
FETCH, or STORE command with arguments appropriate for the associated command.
However, the numbers in the message set argument are unique identifiers instead of
message sequence numbers.
The number after the "*" in an untagged FETCH response is always a message sequence
number, not a unique identifier, even for a UID command response. However, server
implementations must implicitly include the UID message data item as part of any
FETCH response caused by a UID command, regardless of whether a UID was specified
as a message data item to the FETCH.
6. PSEUDOCODE FOR THE COMPONENTS
6.1 Mailbox Display
Aim:
The aim of this component is to display the mails that are present
in the mailbox.
Pseudo code:
Get the urladdress of the $mailbox;
if the $mailbox is INBOX or INBOX.Trash
the format of display should be From field followed by
Date, Size and Subject fields.
else if the $mailbox is INBOX.Sent of INBOX.Draft,
the format should be To field followed by the fields Date,
Size and Subject fields respectively.
Get the start message of the message. Print the messages in the
order of their uid.
If any mail is deleted from the mailbox, rearrange them.
If any mail is selected for display, call the function
message_display.
Aim:
The aim of this component is to display the selected message.
Pseudocode:
Get the $uid of the message and $mailbox.
Create a imapconnection with the username, key and session
values and then fetch the message $uid from $mailbox .
Assign the header fields to the local variables and use the html tags
to display the message.
Logout imapconnection
Aim:
The aim of this component is to compose new mails, forward or
reply the mails.
Pseudocode:
Create a new login session with the imapconnection, key and other
session values.
If not a fresh mail
{
If it is replying to a message
{
get the uid of the message
To address is the from address of the old message.
Append to the body the original body through FETCH command
Now add the replying text to the text body }
Elseif it is forwarding to some user
{
append to the body of the address field through the fetch
command.
Add the to address field
Add the cc and bcc fields if wanted
} }
else if it is a fresh mail
{
add the to address fields, subject and other fields and write
the text message.
}
Upon finish
If save as draft button is pressed, store the mail in the
INBOX.Draft mailbox
Else if send button is pressed, send the mail through the Sendmail
server.
Logout the imapconnection.
7. RESULTS
The results were tested and observed to be successful for the test
data. The testing of the implemented functionalities was satisfying and were according to
the design.
It is a well organized intranet system at the end and also a good
graphical interface is established. There are no flaws in the implementation of our code
and the results were as expected.
The project ensures that the user will have no problem in performing
the basic functions like deleting messages, arranging folders, composing mails etc.
8. CONCLUSION AND FUTURE WORK
More features can also be added for the user. More functionality like
searching the email ids of the existing users, creating and deleting folders, etc can also be
implemented.
REFERENCES
4. PHP tutorial:http//www.php.net
5. Ashok Appu: PHP-A Beginner’s Guide, First edition, Wiley publishing Inc, 2002.
6. http://campusconnect.infosys.com
// Retrieves a list with headers, flags, size or internaldate from the imap server
/*
* We need to return the data in the same order as the caller supplied
* in $msg_list, but IMAP servers are free to return responses in
* whatever order they wish... So we need to re-sort manually
*/
for ($i = 0; $i < sizeof($msg_list); $i++) {
$messages["$msg_list[$i]"] = array();
}
$read = implode('',$r);
break;
case 'INTERNALDATE':
$date = parseString($read,$i);
break;
case 'BODY.PEEK[HEADER.FIELDS':
case 'BODY[HEADER.FIELDS':
$i = strpos($read,'{',$i);
$header = parseString($read,$i);
if ($header === false) break 2;
/* First we replace all \r\n by \n, and unfold the header */
$hdr = trim(str_replace(array("\r\n", "\n\t", "\n "),array("\n", ' ', ' '), $header));
/* Now we can make a new header array with */
/* each element representing a headerline */
$hdr = explode("\n" , $hdr);
foreach ($hdr as $line) {
$pos = strpos($line, ':');
if ($pos > 0) {
$field = strtolower(substr($line, 0, $pos));
if (!strstr($field,' ')) { /* valid field */
$value = trim(substr($line, $pos+1));
switch($field)
{
case 'to': $to = $value; break;
case 'cc': $cc = $value; break;
case 'from': $from = $value; break;
case 'date': $date = $value; break;
case 'subject':
$subject = $value;
if ($subject == "") {
$subject = "no subject";
}
break;
case 'content-type':
$type = $value;
if ($pos = strpos($type, ";")) {
$type = substr($type, 0, $pos);
}
$type = explode("/", $type);
if(!is_array($type)) {
$type[0] = 'text';
}
break;
default: break;
}
}
}
}
break;
default:
++$i;
break;
}
}
if (isset($date)) {
$date = str_replace(' ', ' ', $date);
$tmpdate = explode(' ', trim($date));
} else {
$tmpdate = $date = array();
}
if ($uid_support) {
$msgi ="$unique_id";
$messages[$msgi]['ID'] = $unique_id;
} else {
$msgi = "$id";
$messages[$msgi]['ID'] = $id;
}
$messages[$msgi]['TIME_STAMP'] = getTimeStamp($tmpdate);
$messages[$msgi]['DATE_STRING'] = getDateString($messages[$msgi]
['TIME_STAMP']);
$messages[$msgi]['FROM'] = $from; //parseAddress($from);
$messages[$msgi]['SUBJECT'] = $subject;
;
$messages[$msgi]['CC'] = $cc;
$messages[$msgi]['SIZE'] = $size;
$messages[$msgi]['TYPE0'] = $type[0];
$messages[$msgi]['FLAG_DELETED'] = $flag_deleted;
$messages[$msgi]['FLAG_ANSWERED'] = $flag_answered;
$messages[$msgi]['FLAG_SEEN'] = $flag_seen;
$messages[$msgi]['FLAG_FLAGGED'] = $flag_flagged;
++$msgi;
}
array_reverse($messages);
$new_messages = array();
foreach ($messages as $i =>$message) {
$new_messages[] = $message;
}
return $new_messages;
}
?>