- Each email message is nothing but a text file plus the attachments.
What is SMTP?
- SMTP is the internet standard for e-mail transmission across Internet Protocol (IP) networks.
- SMTP uses TCP port 25.
- SMTP is based on end-to-end message delivery.
How email works?
- Assume that i want to send a piece of email.
- My email address is : firstname.lastname@example.org and i want to send email to: email@example.com.
- I am using an email client like Outlook Express.
- When I send the email, Outlook Express connects to gmail service’s SMTP mail server using port 25.
- Server is a centralized computer which manages access to resource or service in a network.
- Outlook Express sends the SMTP server:
1. address of sender.
2. address of recepient.
3. body of message.
- SMTP server takes the recipient address and breaks it into two parts:
1. recipient name: xyzperson
2. domain name: yahoo.com
- If the domain name of sender and reciever would have been same, then SMTP server simply transfers the mail to the local outgoing mail server (POP3 or IMAP) using a little program called the delivery agent. But here the recipient is at another domain, so SMTP needs to communicate with that domain.
- SMTP server of gmail.com converses with Domain Name Server (DNS) and asks for IP address of SMTP server at yahoo.com
- SMTP server of gmail.com hands over the email message to the SMTP server of yahoo.com using port 25.
- SMTP server at yahoo.com checks that the recipient address belongs to it or not. It hands the email to its counterpart: POP3 or IMAP server.
- Post Office Protocol (POP3) servers are the servers that do the job of receiving mails. The number ““3 is the version number of the protocol in use.
- POP3 servers have mail accounts i.e our email IDs.
- Once the message is handed over to the POP3 server, it is kept and stored in the mail account till the recipient logs in and checks the mail.
- An email client connects to the POP3 server and tells it to allow download of the email. Once downloaded to the local machine, POP3 mailboxes do not retain a copy of the email. Thus, you cannot check your emails from another PC as it has already been downloaded.
- But to nail this difficulty, IMAP was introduced. IMAP4 (Internet Message Access Protocol version 4) simply retains a copy of the emails on the server. This allows you to access your e-mail from any location with an internet connection.
- If for some reason, the SMTP server at gmail cannot connect with the SMTP server at yahoo, then the message goes into a queue.
- SMTP server on most machines uses a program called sendmail to do the actual sending, so this queue is called the sendmail queue.
- Sendmail will periodically try to resend the messages in its queue. For example, it might retry every 15 minutes. After four hours, it will usually send you a piece of mail that tells you there is some sort of problem. After five days, most sendmail configurations give up and return the mail to you undelivered.
- HELO – introduce yourself
- EHLO – introduce yourself and request extended mode
- MAIL FROM: – specify the sender
- RCPT TO: – specify the recipient
- DATA – specify the body of the message (To, From and Subject should be the first three lines.)
- RSET – reset
- QUIT – quit the session
- HELP – get help on commands
- VRFY – verify an address
- EXPN – expand an address
- VERB – verbose
What is API?
- API stands for Application Programming Interface.
- An interface is a medium via which two systems communicate.
- API is the interface implemented by an application which allows other applications to communicate with it.
- It is a particular set of rules (code) and specifications that software applications can follow to communicate with each other.
- It is a software-to-software interface, not a user interface. With APIs, applications talk to each other without any user intervention.
- APIs offer less flexibility than open source code but more flexibility than completely closed applications.
- APIs are specially crafted to expose only chosen functionality and/or data while safeguarding other parts of the application which provides the interface.
Why do we need API?
- To communicate between applications.
- Example: When you copy and paste text from one application to another, it is the API that allows that to work (like copy text from Notepad and paste to Google Chrome or Mozilla Firefox).
- Example: Facebook. You can interact with Facebook whether you are using a mobile phone, a smart phone, an iPod or a computer. This has been made possible by the excellent Facebook API.
- Example: Yelp. It has data on restaurants, hotels, shopping destinations and other local services. if they create their own Maps engine to let users know where the various destinations are, it would be a wasteful and tedious job. So, they tap into the Google Maps API and plot their data on top of it, thereby increasing the utility of their service to the end user.
- API can be used for: 1. Extending a platform 2. Creating mashups
- Extending a platform means the application can be used on various devices.
- Mashup is created when you combine data and functionality from more than one application to create another application.
- Google Maps API, Twitter API, Youtube API, Flickr API are few popular APIs
- Find a complete, classified and searchable directory of APIs at “Programmable Web” and “WebMashup“.
How to use APIs?
- API is the proper way to request services from a program by a developer.
- API comes in two forms:
1. In the form of library which includes specifications for routines, data structures, object classes and variabls.
2. As just a specification of remote calls (mainy for SOAP and REST services)
- Developers can make requests by:
1. Establishing a reference to a library in your software or importing a function.
2. Making remote calls.
- The syntax is described in the documentation of the application being called.
- Thus, API grants access to open an application.
How API works?
- API allows a software application to communicate with a remote application over the Internet through a series of calls.
- The calls back and forth between applications are managed through Web services.
- In web development, an API is a set of
1. Hypertext Transfer Protocol (HTTP) request messages and
- Each response message corresponds to a different function of the remote service.
- Developer programs new or existing software to generate the right response messages.
Advantages of API
- Facebook released its API so that developers could create widgets or small applications that add new functionality to the popular site. Advantage: Popularity and increasing brand recognition.
- API is sometimes related to software library.
- API describes and prescribes the expected behaviour while software library is actual implementation of this set of rules.
- API can have multiple implementations (or none, being abstract) in the form of different libraries that share the same programming interface.