컴퓨터 네트워크 - Application Layer : SMTP

TopOfTheHead·2025년 8월 12일

컴퓨터네트워크

목록 보기
13/21

전자메일 ( Electronic Mail )
Mail MessageUser Agent에서 작성되어 송신자Mail Server를 거쳐 수신자Mail ServerMailbox로 저장됨.

  • 전자메일의 주요 3요소
    User Agent , Mail Server , Mail Protocol
    • User Agent
      Mail Message를 작성 , 편집 , 읽는 역할을 수행하는 프로그램
      ex ) Gmail

      Mail MessageMail Server로 전송 및 Mail ServerMailbox에서 Mail Message를 가져오는 역할을 수행

    • Mail Server
      Electronic Mail Structure의 중심

      송/수신자 Mail ServerUser Agent를 통해 작성된 Mail Message의 전송 및 저장을 수행
      ex ) Naver , 학교

      Mail Server의 두가지 자료구조

      • Mailbox :
        송신자 Mail Server에서 전송한 Mail Message를 저장하는 저장소
        ▶ 각 사용자Mail Server 내 고유의 Mailbox를 포함

      • Message Queue
        。다른 수신자 Mail Server에게 송신할 Mail Message를 발송 시 임시로 보관하는 저장소
        Mailbox와 달리 사용자 구분이 없음.

        수신자 Mail Server가 고장나서 수신이 불가능한 경우 임시로 Message Queue에 저장하여 약 30분의 간격으로 재시도


    • Mail Protocol

      송신자 쪽에서 User Agent를 통해 Mail Message를 작성하면서 송신자 Mail Server - 수신자 Mail Server로 전달( push )하는 방식은 SMTP 프로토콜을 통해 정의


      수신자 Mail ServerMailbox에 저장된 Mail Message수신자User Agent를 통해 가져오는 방식( pull )은 Mail Access Protocol ( POP , IMAP , HTTP 프로토콜 등 )을 통해 정의

SMTP ( Simple Mail Transfer Protocl ) [RFC 5321]
전자메일을 위한 어플리케이션 계층 프로토콜

Mail Server송신자 / 수신자 프로세스Client-Server Architecture를 가진다.
SMTP Client : SMTP를 사용하는 송신자 Mail Server 프로세스
SMTP Server : SMTP를 사용하는 수신자 Mail Server 프로세스
Message Mail 전송 시 SMTP Client로 동작 , Message Mail 수신 시 SMTP Server로 동작

트랜스포트 계층 프로토콜로서 TCP를 사용
SMTP Server 프로세스Port번호 : 25

SMTPMail Message7 bit ASCII를 사용하므로 전송용량이 제한.
▶ 현재는 다른 Mail Protocol을 통해 대용량 파일이나 이미지 등을 전송가능

SMTPPush 프로토콜로서 전송만 가능
Mail Server에서 Mail Message를 가져올때는 Pull 프로토콜Mail Access Protocol ( POP , IMAP , HTTP 프로토콜 등 )을 사용

  • HTTPSMTP 차이점
    。둘다 ASCII 기반 command / response를 가지며 Responsestatus code & status phrase를 가지지만 아래부분에서 차이가 발생.
    • HTTP : pull 프로토콜
      HTTP ClientHTTP Server로부터 직접 데이터 객체pull 하는 방식이므로

    • SMTP : push 프로토콜
      SMTP ClientSMTP ServerMail Messagepush 하는 방식이므로

SMTP 원리

  • 송신자는 User Agent를 통해 Mail Message를 작성후 수신자 전자메일 주소로 전송하도록 명령

  • 송신자 User AgentMail Message송신자 Mail ServerMessage Queue로 전송

  • 송신자 Mail ServerSMTP Client수신자 Mail ServerSMTP ServerTCP Connection을 수행
    SMTP Server 프로세스Port번호 : 25SMTP Client 프로세스TCP Connection 수행
    TCP Connection이 설정된 경우 SMTP ServerSMTP ClientSMTP Handshaking이 수행됨.

  • SMTP Handshaking이 될 경우 SMTP Client에서 송신자 Mail Server Message QueueMail MessageTCP 소켓으로 전송
    。전송이 모두 끝난 경우 SMTP Command : QUIT를 통해 TCP Connection을 종료

  • 수신자 Mail ServerSMTP Server가 수신한 Mail MessageMailbox에 저장

SMTP Interaction 시 3가지 전송절차
SMTP ClientMail MessageCommand를 포함
SMTP Command : ASCII 명령문 ( HELO , MAIL FROM , RCPT TO , CRLF , DATA , QUIT ,... )

SMTP ServerMail MessageResponse를 포함
SMTP Response : ASCII Status code & Status phrase로 구성

telnet 호스트이름 25를 통해 SMTP ServerTCP 연결 이후 다음 CommandResponse를 입력하면서 SMTP Interaction 수행
telnet 호스트이름 25를 선언한 경우 호스트이름원격 Mail ServerLocal HostTCP Connection이 수행됨.
ex ) telnet hamburger.edu 25


C : SMTP Client , S : SMTP Server

  • 가정
    SMTP Client Host name : crepes.fr
    SMTP Server Host name : hamburger.edu

    Do you like ketchup? How about pickles?이라는 Mail Message 전송

  • Handshaking = greeting
    STMP ServerSMTP Client 간 소개를 통해 송/수신자Host name를 소개

    220 hamburger.edu : SMTP ServerHost name
    ResponseStatus code & Status phrase로 구성

  • transfer of messages
    SMTP Handshaking 이후 SMTP Client에서 SMTP ServerMail MessageTCP Connection 상에서 송신

    TCP Connection이 지속연결 되는동안 .을 통해 구분하면서 Mail Message의 연이은 전송이 가능
    SMTP ClientQUIT를 전송하는 경우 TCP Connection이 종료

  • closure
    。전송할 Mail Message가 없는 경우 TCP에게 TCP Connection을 종료하도록 명령

Mail Access Protocol
수신자 User Agent에서 수신자 Mail ServerMail Message를 가져올때 사용하는 Pull 프로토콜이자 애플리케이션 계층 프로토콜
SMTPMail Message의 전송 및 저장만 가능한 Push 프로토콜로서 Mail Message를 가져오는 기능은 없다.

  • Mail Access Protocol 종류
    • POP ( Post Office Protocol ) [RFC 1939]

    • IMAP ( Internet Mail Access Protocol ) [RFC 1730]

    • HTTP
profile
공부기록 블로그

0개의 댓글