Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
pop3.h
00001 /* 00002 * POP3 library 00003 * Copyright (c) 2010 Hendrik Lipka 00004 * 00005 * Permission is hereby granted, free of charge, to any person obtaining a copy 00006 * of this software and associated documentation files (the "Software"), to deal 00007 * in the Software without restriction, including without limitation the rights 00008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 * copies of the Software, and to permit persons to whom the Software is 00010 * furnished to do so, subject to the following conditions: 00011 * 00012 * The above copyright notice and this permission notice shall be included in 00013 * all copies or substantial portions of the Software. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00021 * THE SOFTWARE. 00022 */ 00023 00024 #ifndef __POP3_H__ 00025 #define __POP3_H__ 00026 00027 #include <string> 00028 #include <list> 00029 00030 #include "tcplinestream.h" 00031 00032 using namespace std; 00033 00034 /** 00035 The class representing a received mail message. All fields are stored in un-altered form, so character set conversion might need to be performed. 00036 */ 00037 class Pop3Message 00038 { 00039 public: 00040 /** 00041 the UIDL this message has on the server 00042 */ 00043 string id; 00044 /** 00045 the 'From:' header 00046 */ 00047 string from; 00048 /** 00049 the 'Subject:' header 00050 */ 00051 string subject; 00052 /** 00053 the actual mail content, line by line 00054 */ 00055 list<string> content; 00056 00057 }; 00058 00059 class Pop3CommandResponse; 00060 00061 /** 00062 Handling all POP3 related aspects. All operations are synchronous. This class expects a set-up network connection. 00063 00064 Needed libraries: 00065 * DNSResolver 00066 * NetServices (for TCP socket), or NetServicesMin 00067 */ 00068 class Pop3 00069 { 00070 public: 00071 /** 00072 Creates the POP3 handler 00073 00074 @param servername the DNS name of the server 00075 @param username the username 00076 @param password the users password 00077 */ 00078 Pop3(const char* servername, const char* username, const char* password); 00079 00080 /** 00081 closes the connection, and cleans up resources 00082 */ 00083 ~Pop3(); 00084 00085 /** 00086 Retrieve a list of all message IDs. This method doesn't care whether the messages have been read already or not. 00087 The IDs are not sorted, but returned in the order the server delivers them. 00088 00089 @return the list of all message IDs stored at the server. 00090 */ 00091 list<string> *getMessages(); 00092 00093 /** 00094 retrieves as single message 00095 00096 @param id the message ID to retrieve 00097 @param getSig when false, the signature will be stripped (separated by the line '-- ') 00098 @param deleteOnReceive when true the message will be deleted after a sucessful retrieval 00099 @return the message container 00100 */ 00101 Pop3Message* getMessage(string id, bool getSig=false, bool deleteOnReceive=false); 00102 00103 /** 00104 @param id the ID of the message to be deleted 00105 @return true if the deletion was sucessful 00106 */ 00107 bool deleteMessage(string id); 00108 00109 /** 00110 Connects to the server. Needs the ethernet connection already set up. 00111 00112 @return true if the connection has been made (and the user logged in) 00113 */ 00114 bool init(); 00115 00116 /** 00117 closes the connection, and cleans up resources 00118 */ 00119 void close(); 00120 00121 private: 00122 Pop3CommandResponse* sendCommand(string cmd); 00123 Pop3CommandResponse* sendCommandMultiResponse(string cmd); 00124 00125 TCPLineStream *_stream; 00126 00127 const char* _username; 00128 const char* _password; 00129 const char* _servername; 00130 00131 bool _closed; 00132 }; 00133 00134 00135 #endif
Generated on Wed Jul 13 2022 02:57:50 by
1.7.2
POP3