Closed ikemuc closed 7 years ago
Just a thought but I think asking for 100,000 messages might be a problem. Have you tried less?
On 12 Feb 2017, at 16:37, ikemuc notifications@github.com wrote:
I try to access my IMAP server with this code, which is based on your demo code:
`
import Foundation import Postal
class MailManagerPostal { var configuration: Configuration!
fileprivate lazy var postal: Postal = Postal(configuration: self.configuration) fileprivate var messages: [FetchResult] = [] init(hostname: String, userName: String, password: String) { log.debug("init called...") configuration = Configuration(hostname: hostname, port: 993, login: userName, password: .plain(password), connectionType: .tls, checkCertificateEnabled: false) log.debug("configuration created: \(self.configuration.description)") postal.connect(timeout: Postal.defaultTimeout, completion: { [weak self] result in log.debug("postal.connect completed.") switch result { case .success: log.debug("fetching messages now.") let indexset = IndexSet(0...100000) self?.postal.fetchMessages("INBOX", uids: indexset, flags: [ .fullHeaders ], onMessage: { message in log.debug("message : \(message.header)") self?.messages.insert(message, at: 0) }, onComplete: { error in if let error = error { log.error("fetch failed: \((error as NSError).localizedDescription)") } else { log.debug("connection successful") } log.debug("fetch complete.") }) case .failure(let error): log.error("connection failed: \((error as NSError).localizedDescription)") } }) log.debug("init finished.") }
} `
Problem: The last message I see is "fetching messages now.". Then nothing happens any more. WHat's happening here? Where is my mistake? The credentials I use work with using mailcode2 without a problem.
Some more questions:
How can I debug the IMAP requests? Where can I find a documentation of the API? Can I manipulate message, especially add custom headers to a message (or take a message, add custom headers, write it as a new message to the server and delete the old one...)? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/snipsco/Postal/issues/49, or mute the thread https://github.com/notifications/unsubscribe-auth/ABe-sJlBM81qD0mwWRSIi5R9PX_E7G7Nks5rbzVJgaJpZM4L-iZq.
The first try was exactly the demo code with fetchLast() with 50 messages. It didn't work. Then I tried fetchLast() with 3 messages. Then I changed it to fetchMessages... Always the same problem...
I had a problem which is fixed in version v0.4.1. fetchLast had a bug. See:
https://github.com/snipsco/Postal/issues/44 https://github.com/snipsco/Postal/issues/44
On 12 Feb 2017, at 17:29, ikemuc notifications@github.com wrote:
The first try was exactly the demo code with fetchLast() with 50 messages. It didn't work. Then I tried fetchLast() with 3 messages. Then I changed it to fetchMessages... Always the same problem...
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/snipsco/Postal/issues/49#issuecomment-279233803, or mute the thread https://github.com/notifications/unsubscribe-auth/ABe-sFTaL08txDeETcNxHncd5n9hWeAdks5rb0FwgaJpZM4L-iZq.
Tested it with 0..10 just to make sure. Same problem.
I updated to 0.4.1 today, that didn't solve the problem...
My issue was fixed with 0.4.1 but it sounds like you have a different issue.
I shifted the initialization of postal to the init() method and now it works.
class KanbanManagerPostal {
var configuration: Configuration!
var messages: [FetchResult] = []
init(hostname: String, userName: String, password: String) {
log.debug("init called...")
configuration = Configuration(hostname: hostname, port: 993, login: userName, password: .plain(password), connectionType: .tls, checkCertificateEnabled: false)
var postal: Postal = Postal(configuration: configuration)
[...]
Now there are only the other questions unanswered ;-)
@ikemuc To answer your questions:
- How can I debug the IMAP requests? You can set a closure on a Postal instance to have IMAP logs:
let postal = Postal(configuration: ...)
postal.logger { log in
print(log)
}
- Where can I find a documentation of the API?
Unfortunately there isn't yet an official documentation of the API but we documented every public functions that you can access through xcode but I agree it's not enough. Everything should be ok to add jazzy or something like that if you want to do it, PR are welcome ! :)
- Can I manipulate a message, especially add custom headers to a message (or take a message, add custom headers, write it as a new message to the server and delete the old one...)?
No, Postal was first designed in first place only for fetching messages, not manipulating them. But I don't think it would be hard to add such features since libetpan propose an API for that.
Your issue seems fixed so I close it. If you want new features, please submit an issue and we'll figure out how to implement them as quickly as possible 👍
I try to access my IMAP server with this code, which is based on your demo code:
`
`
Problem: The last message I see is "fetching messages now.". Then nothing happens any more. What's happening here? Where is my mistake? The credentials I use work with using mailcode2 without a problem.
Some more questions: