C#で書いた.NET Framework/Mono用POP3クライアントライブラリです。 POPサーバからのメールボックスのステータス取得、メッセージのダウンロード・削除が出来ます。
その他、サポートしている機能の詳細は「実装済み機能一覧」の項をご覧ください。
クライアント実装として以下の3つのクラスを用意しています。
本ライブラリはMIT X11ライセンスでのリリースとなります。
もっとも簡単なサンプルコードとして、System.Net.WebClientクラスとPOP URLを使ったメッセージのダウンロード方法を例示します。 Gmailアカウントにアクセスし、メッセージをダウンロードしてファイルに保存するサンプルです。
using System; using System.Net; using Smdn.Net.Pop3.WebClients; class GpopRetrieveExample { public static void Main() { PopWebRequestCreator.RegisterPrefix(); PopSessionManager.ServerCertificateValidationCallback += delegate { return true; }; using (var client = new WebClient()) { client.Credentials = new NetworkCredential("username", "password"); client.DownloadFile("pops://username@pop.gmail.com/;MSG=1", "message.eml"); } } }
Imports System Imports System.Net Imports System.Net.Security Imports System.Security.Cryptography.X509Certificates Imports Smdn.Net.Pop3.WebClients Class GpopRetrieveExample Public Shared Sub Main() PopWebRequestCreator.RegisterPrefix() PopSessionManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateRemoteCertificate) Using client As New WebClient() client.Credentials = New NetworkCredential("username", "password") client.DownloadFile("pops://username@pop.gmail.com/;MSG=1", "message.eml") End Using End Sub Private Shared Function ValidateRemoteCertificate(ByVal sender As Object, _ ByVal certificate As X509Certificate, _ ByVal chain As X509Chain, _ ByVal sslPolicyErrors As SslPolicyErrors) As Boolean Return True End Function End Class
この例で使用している修飾子(;MSG=1)はPOP URLに対する独自の拡張です。 詳細・その他のサンプルコードはドキュメント・サンプルおよびデモ用アプリケーションMRAConnector, TundereBirdをご覧ください。
サポートするPOP標準仕様・拡張仕様の一覧です。
| RFC | status | note |
| RFC | status | note |
| [RFC 1939] Post Office Protocol - Version 3 | implemented | |
| [RFC 2384] POP URL Scheme | implemented | [独自拡張]URLのスキームがpopsの場合、デフォルトポートとして995を使用し、SSLによる接続を試みます。 また、修飾子;MSG=が含まれている場合、メールボックス内の特定のメッセージを表すURLとして解釈します。 |
| [RFC 2449] POP3 Extension Mechanism | partially implemented | LOGIN-DELAY, PIPELINING, EXPIREに関連する機能は未実装です。 また、レスポンスコードが含まれていても通常のレスポンスと同様*1に扱います。 |
| [RFC 2595] Using TLS with IMAP, POP3 and ACAP | implemented | |
| [RFC 3206] The SYS and AUTH POP Response Codes | partially implemented | レスポンスコードが含まれていても通常のレスポンスと同様*1に扱います。 |
| [RFC 5034] The Post Office Protocol (POP3) Simple Authentication and Security Layer (SASL) Authentication Mechanism | implemented | |
| [RFC 5721] POP3 Support for UTF-8 | not implemented |
以下のPOPサーバに対して概ね問題なく動作することを確認済みです。
以下の環境で概ね問題なく動作することを確認済みです。 テストはしていますが、予期しないバグがあるかもしれません。