imap.gmail.com:993의 IMAP 서버와 pop.gmail.com:995의 POP 서버에 대한 수신 연결에는 SSL이 필요합니다. 발신 SMTP 서버(smtp.gmail.com)는 TLS를 지원합니다. 클라이언트가 일반 텍스트로 시작하는 경우 STARTTLS 명령어를 실행하기 전에 포트 465 (SSL용) 또는 포트 587 (TLS용)를 사용합니다.
세션 길이 제한
Gmail POP 세션은 약 7일로 제한됩니다. Gmail IMAP 세션은 약 24시간으로 제한됩니다. OAuth 사용자 인증 정보를 사용하여 세션이 인증된 경우 사용된 액세스 토큰의 유효 기간 (일반적으로 1시간)으로 제한됩니다. 이 맥락에서 세션은 하나의 연속적인 TCP 연결입니다.
시간이 지나 세션이 만료되면 Gmail은 세션이 만료되었다는 메시지와 함께 연결을 닫습니다. 그런 다음 클라이언트는 다시 연결하고 다시 인증한 후 계속할 수 있습니다. OAuth를 사용하는 경우 사용된 액세스 토큰이 유효한지 확인하세요 (1시간이 지난 액세스 토큰을 사용하려고 하면 유효하지 않을 수 있음).
라이브러리 및 샘플
IMAP 또는 POP를 사용하여 메일에 액세스하고 SMTP를 사용하여 메일을 보내는 작업은 편의를 위해 기존 IMAP 및 SMTP 라이브러리를 사용하여 수행되는 경우가 많습니다. 이러한 라이브러리가 Simple Authentication and Security Layer (SASL)을 지원하는 한 Gmail에서 지원하는 SASL XOAUTH2 메커니즘과 호환되어야 합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-29(UTC)"],[],[],null,["# IMAP, POP, and SMTP\n\nFor non-Gmail clients, Gmail supports the standard IMAP, POP, and SMTP protocols. The Gmail IMAP, POP, and SMTP servers have been extended to support authorization via the industry-standard OAuth 2.0 protocol.\n\nProtocol\n--------\n\nIMAP, POP, and SMTP use the standard [Simple Authentication and Security Layer (SASL)](https://tools.ietf.org/html/rfc4422), using the built-in the native IMAP `AUTHENTICATE`, POP `AUTH`, and SMTP `AUTH` commands, to authenticate users. The SASL XOAUTH2 mechanism enables clients to provide OAuth 2.0 credentials for authentication. The [SASL XOAUTH2 protocol documentation](/workspace/gmail/imap/xoauth2-protocol) describes the SASL XOAUTH2 mechanism in great detail, and [libraries and samples](/workspace/gmail/imap/xoauth2-libraries) which have implemented the protocol are available.\n\nIncoming connections to the IMAP server at `imap.gmail.com:993` and the POP server at `pop.gmail.com:995` require SSL. The outgoing SMTP server, `smtp.gmail.com`, supports TLS. If your client begins with plain text, before issuing the STARTTLS command, use port `465` (for SSL), or port `587` (for TLS).\n\nSession length limits\n---------------------\n\nGmail POP sessions are limited to about 7 days. Gmail IMAP sessions are limited to about 24 hours. If the session was authenticated using OAuth credentials, it's limited to about the validity period of the access token used (usually 1 hour). A session in this context is one continuous [TCP connection](https://en.wikipedia.org/wiki/Transmission_Control_Protocol).\n\nWhen the time elapses and the session expires, Gmail closes the connection with a message saying that the session expired. After that, the client can reconnect, authenticate again, and continue. If using OAuth, make sure that the access token used is valid (if you try to use an access token older than 1 hour, it might be invalid).\n\nLibraries and Samples\n---------------------\n\nAccessing mail using IMAP or POP and sending mail using SMTP is often done using existing IMAP and SMTP libraries for convenience. As long as these libraries support the [Simple Authentication and Security Layer (SASL)](https://tools.ietf.org/html/rfc4422), they should be compatible with the SASL XOAUTH2 mechanism supported by Gmail.\n\nIn addition to the SASL XOAUTH2 [protocol documentation](/workspace/gmail/imap/xoauth2-protocol), you may also want to read [Using OAuth 2.0 to Access Google APIs](https://developers.google.com/identity/protocols/OAuth2) for further information on implementing an OAuth 2.0 client.\n\nThe [Libraries and Samples](/workspace/gmail/imap/xoauth2-libraries) page provides code samples in a variety of popular languages using the SASL XOAUTH2 mechanism with either IMAP or SMTP."]]