IMAP، POP و SMTP
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
برای مشتریان غیر Gmail، Gmail از پروتکل های استاندارد IMAP، POP و SMTP پشتیبانی می کند. سرورهای Gmail IMAP، POP و SMTP برای پشتیبانی از مجوز از طریق پروتکل استاندارد صنعتی OAuth 2.0 گسترش یافته اند.
پروتکل
IMAP، POP، و SMTP از احراز هویت ساده و لایه امنیتی (SASL) با استفاده از دستورات داخلی IMAP AUTHENTICATE
، POP AUTH
و SMTP AUTH
برای احراز هویت کاربران استفاده می کنند. مکانیسم SASL XOAUTH2 مشتریان را قادر می سازد تا اعتبارنامه های OAuth 2.0 را برای احراز هویت ارائه کنند. مستندات پروتکل SASL XOAUTH2 مکانیسم SASL XOAUTH2 را با جزئیات کامل توصیف می کند و کتابخانه ها و نمونه هایی که پروتکل را پیاده سازی کرده اند در دسترس هستند.
اتصالات ورودی به سرور IMAP در imap.gmail.com:993
و سرور POP در pop.gmail.com:995
به SSL نیاز دارند. سرور SMTP خروجی، smtp.gmail.com
، از TLS پشتیبانی می کند. اگر کلاینت شما با متن ساده شروع می شود، قبل از صدور دستور STARTTLS، از پورت 465
(برای SSL) یا پورت 587
(برای TLS) استفاده کنید.
محدودیت طول جلسه
جلسات Gmail POP حدود 7 روز محدود است. جلسات IMAP Gmail به حدود 24 ساعت محدود می شود. اگر جلسه با استفاده از اعتبارنامه OAuth احراز هویت شده باشد، تقریباً به مدت اعتبار رمز دسترسی استفاده شده (معمولاً 1 ساعت) محدود می شود. یک جلسه در این زمینه یک اتصال TCP پیوسته است.
هنگامی که زمان سپری می شود و جلسه منقضی می شود، Gmail با پیامی مبنی بر منقضی شدن جلسه اتصال را می بندد. پس از آن، کلاینت می تواند دوباره وصل شود، دوباره احراز هویت کند و ادامه دهد. اگر از OAuth استفاده می کنید، مطمئن شوید که نشانه دسترسی استفاده شده معتبر است (اگر سعی کنید از یک نشانه دسترسی قدیمی تر از 1 ساعت استفاده کنید، ممکن است نامعتبر باشد).
کتابخانه ها و نمونه ها
دسترسی به نامه با استفاده از IMAP یا POP و ارسال نامه با استفاده از SMTP اغلب با استفاده از کتابخانه های IMAP و SMTP موجود برای راحتی انجام می شود. تا زمانی که این کتابخانه ها از احراز هویت ساده و لایه امنیتی (SASL) پشتیبانی می کنند، باید با مکانیسم SASL XOAUTH2 پشتیبانی شده توسط Gmail سازگار باشند.
علاوه بر اسناد پروتکل SASL XOAUTH2، ممکن است بخواهید برای کسب اطلاعات بیشتر در مورد اجرای یک کلاینت OAuth 2.0 ، استفاده از OAuth 2.0 برای دسترسی به APIهای Google را مطالعه کنید.
صفحه کتابخانه ها و نمونه ها با استفاده از مکانیسم SASL XOAUTH2 با IMAP یا SMTP، نمونه های کد را در انواع زبان های رایج ارائه می دهد.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[],[],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."]]