Question: For this project, you will write an email client application which sends and receives mail using the Internet standards, SMTP, and POP3. AUTOMATE THE BELOW
For this project, you will write an email client application which sends and receives mail using the Internet standards, SMTP, and POP3.
AUTOMATE THE BELOW TELNET SESSION USING SMTP AND POP3 PROTOCOLS
=================================================
SEND MAIL
=================================================
[ab1234@csweb01 ~]$ telnet hopper.csueastbay.edu 25
Trying 134.154.190.225...
Connected to hopper.csueastbay.edu.
Escape character is '^]'.
220 hopper.csueastbay.edu ESMTP Postfix
HELO csweb01.csueastbay.edu
250 hopper.csueastbay.edu
MAIL FROM:
250 2.1.0 Ok
RCPT TO:
250 2.1.5 Ok
DATA
354 End data with
Subject: Program #4
This isn't so hard :)
.
250 2.0.0 Ok: queued as 1F582A4
QUIT
221 2.0.0 Bye
Connection closed by foreign host.
[ab1234@hopper ~]$ mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/ab1234": 3 messages 1 new 2 unread
1 john.smith@csueastb Fri Nov 2 15:19 12/404 "Looking good"
U 2 john.smith@csueastb Fri Nov 2 15:28 12/405 "Message 2"
>N 3 john.smith@csueastb Sun Nov 4 14:14 11/400 "Program #4"
&
=================================================
RECEIVE MAIL
=================================================
[ab1234@csweb01 ~]$ telnet hopper 110
Trying 134.154.190.225...
Connected to hopper.
Escape character is '^]'.
+OK [XCLIENT] Dovecot ready.
USER ab1234
+OK
PASS yourpasswordhere
+OK Logged in.
LIST
+OK 3 messages:
1 343
2 345
3 350
.
RETR 3
+OK 350 octets
Return-Path:
X-Original-To: ab1234
Delivered-To: ab1234@hopper.csueastbay.edu
Received: from csweb01.csueastbay.edu (csweb01.csueastbay.edu [134.154.190.215])
by hopper.csueastbay.edu (Postfix) with SMTP id 1F582A4
for
Subject: Program #4
This isn't so hard :)
.
DELE 3
+OK Marked to be deleted.
LIST
+OK 2 messages:
1 343
2 345
.
QUIT
+OK Logging out, messages deleted.
Connection closed by foreign host.
=================================================
PROGRAMS TO GET YOU STARTED
=================================================
/* TCPRCV.C */
#include
#define TRUE 1
/* This is the receiver program. It opens a socket, sets the receive window as requested, and then begins an infinite loop. Each time through the loop it accepts a connection and prints out messages from it. When the connection breaks or a termination message comes through it, the program accepts a new connection. The form of the command line is: 'tcprcv' */
main() { int sd, length; struct sockaddr_in rcvr; int sda; int buflen = 800; char buf[1500]; int rcvwin, optlen; int rval; int seqno;
rcvwin = buflen;
/* create socket */ sd = socket(AF_INET, SOCK_STREAM, 0); if(sd < 0) { perror("opening stream socket"); exit(1); }
/* name socket using wildcards */ rcvr.sin_family = AF_INET; rcvr.sin_addr.s_addr = INADDR_ANY; rcvr.sin_port = 0; if(bind(sd, (struct sockaddr *)&rcvr, sizeof(rcvr))) { perror("binding socket name"); exit(1); }
/* find out assigned port number and print out */ length = sizeof(rcvr); if(getsockname(sd, (struct sockaddr *)&rcvr, &length)) { perror("getting socket name"); exit(1); } printf("Socket has port #%d ",ntohs(rcvr.sin_port));
rcvwin = buflen;
/* Accept connections from the transmitter */ listen(sd, 5); do { sda = accept(sd,0,0); if(sda == -1) perror("accept"); else do { bzero(buf,sizeof(buf)); if((rval = recv(sda,buf,rcvwin,MSG_WAITALL))<0) perror("reading message stream"); if(rval == 0) printf("Ending connection "); else { sscanf(buf, "%d", &seqno); printf("Received packet: seqno = %d length = %d ", seqno, rval); } }while (rval != 0); close(sda); }while (TRUE); }
=================================================
/* TCPXMIT.C */
#include
/* This is the transmitter program. It creates a socket and initiates a connection with the socket given in the command line. The send buffer is set as requested. One message is sent over the connection and then the socket is closed. The form of the command line is `tcpxmit rcvr-hostname rcvr-port'. */
main(int argc,char *argv[]) { int sd; struct sockaddr_in rcvr; struct hostent *hp, *gethostbyname(); int buflen = 512; char buf[1500]; int sndwin, optlen; struct timeval sndtime; struct timezone zone; int rval, seqno;
sndwin = buflen;
/* create socket */ sd = socket(AF_INET, SOCK_STREAM, 0); if(sd < 0) { perror("Opening stream socket"); exit(1); }
/* Create rcvr socket address using command line arguments */ rcvr.sin_family = AF_INET; hp = gethostbyname(argv[1]); if(hp == 0) { printf("%s: unknown host ",argv[1]); exit(2); } bcopy(hp->h_addr, &rcvr.sin_addr, hp->h_length); rcvr.sin_port = htons(atoi(argv[2]));
/* connect socket using name specified at command line */ if(connect(sd, (struct sockaddr *)&rcvr, sizeof(rcvr)) < 0) { perror("connecting stream socket"); exit(1); }
if (gettimeofday(&sndtime, &zone) < 0) { perror("Getting time"); } printf("Start time: %ld %ld ", sndtime.tv_sec, sndtime.tv_usec);
/* create a packet */ seqno = 1; sprintf(buf, "%d\0", seqno);
/* send the packet */ if((rval=write(sd, buf, sndwin)) < 0) { perror("writing on stream socket"); } else { printf("Sent packet of length %d ", rval); }
close(sd); }
=================================================
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
