IMAP、POP、SMTP
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Gmail 以外のクライアントの場合、Gmail は標準の IMAP、POP、SMTP プロトコルをサポートしています。Gmail の IMAP、POP、SMTP サーバーが拡張され、業界標準の OAuth 2.0 プロトコルによる認証がサポートされるようになりました。
プロトコル
IMAP、POP、SMTP は、標準の Simple Authentication and Security Layer(SASL)を使用し、ネイティブの IMAP AUTHENTICATE
、POP AUTH
、SMTP AUTH
コマンドを使用してユーザーを認証します。SASL XOAUTH2 メカニズムを使用すると、クライアントは認証用の OAuth 2.0 認証情報を提供できます。SASL XOAUTH2 プロトコルのドキュメントでは、SASL XOAUTH2 メカニズムについて詳しく説明しています。また、このプロトコルを実装したライブラリとサンプルも利用できます。
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 時間)に制限されます。このコンテキストのセッションは、1 つの連続した TCP 接続です。
時間が経過してセッションが期限切れになると、Gmail はセッションが期限切れになったことを示すメッセージとともに接続を閉じます。その後、クライアントは再接続して再度認証を受け、続行できます。OAuth を使用している場合は、使用するアクセス トークンが有効であることを確認してください(1 時間以上前のアクセス トークンを使用しようとすると、無効になることがあります)。
ライブラリとサンプル
IMAP または POP を使用したメールへのアクセスや、SMTP を使用したメールの送信は、多くの場合、既存の IMAP ライブラリと SMTP ライブラリを使用して行われます。これらのライブラリが Simple Authentication and Security Layer(SASL)をサポートしている限り、Gmail でサポートされている SASL XOAUTH2 メカニズムと互換性があるはずです。
SASL XOAUTH2 プロトコルのドキュメントに加えて、OAuth 2.0 クライアントの実装に関する詳細については、OAuth 2.0 を使用して Google API にアクセスするもご覧ください。
ライブラリとサンプルのページには、IMAP または SMTP で SASL XOAUTH2 メカニズムを使用するさまざまな一般的な言語のコードサンプルが用意されています。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-29 UTC。
[null,null,["最終更新日 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."]]