1 / 10

SMTP

SMTP. CS176A Ramya Raghavendra ramya@cs.ucsb.edu. SMTP. What is SMTP? Simple Mail Transfer Protocol SMTP server – every email client interfaces to send email List of SMTP servers in transit - Check the headers on your email! Why talk directly to SMTP server?

dante
Download Presentation

SMTP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SMTP CS176A Ramya Raghavendra ramya@cs.ucsb.edu

  2. SMTP • What is SMTP? • Simple Mail Transfer Protocol • SMTP server – every email client interfaces to send email • List of SMTP servers in transit - Check the headers on your email! • Why talk directly to SMTP server? • Automation of emails in applications • Without dependency on another email client • Real time notification of status • Wrong ID, passwords etc

  3. Consider Windows alternative like MAPI More complex More overhead Example

  4. Multipart Messages • But can we send multipart messages with attachments? • YES • SMTP is only a delivery mechanism, nothing to do with contents • RFCs on how to create multipart messages with attachments • Your assignment • Simple text

  5. SMTP commands

  6. For testing purposes • Part 1 : • Please note: NO TURNIN • Part 2: • To : command line argument • Subject: cs176aHW3ProgPart2 • Content: Name and Perm no.

  7. Email Sender: Logic /* open the network connection */ sfd = smtpConnect(smtp_server,smtp_port); if (sfd == INVALID_SOCKET) { rc=(-1); goto cleanup; } // Send HELO smtpHelo(sfd,helo_domain); //Send “From” address smtpMailFrom(sfd,from); //Send “To” address smtpRcptTo(sfd);

  8. Email Sender: Logic (Cont) //Send Data smtpData(sfd); //Send End-of-mail “.” smtpEom(sfd); //Send QUIT smtpQuit(sfd);

  9. Connection to SMTP Server /* connect to SMTP server and returns the socket fd */ static SOCKET smtpConnect (char *smtp_server, int port) { SOCKET sfd; sfd=clientSocket(smtp_server,port); if (sfd == INVALID_SOCKET) { errorMsg("Could not connect to SMTP server \"%s\" at port %d\n", smtp_server,port); return (INVALID_SOCKET); } /* save it. we'll need it to clean up */ smtp_socket=sfd; return (sfd); }

  10. One example /* SMTP: HELO */ static int smtpHelo(int sfd,char *helo_domain) { memset(buf,0,sizeof(buf)); (void) snprintf(buf,sizeof(buf)-1,"HELO %s\r\n",helo_domain); //Socket write function sockPuts(sfd,buf); return (smtpResponse(sfd)); }

More Related