mailio icon indicating copy to clipboard operation
mailio copied to clipboard

select folder failed

Open shgli opened this issue 1 year ago • 9 comments

我登录了126邮箱,发现select folder报错: Select or examine mailbox failure. 代码如下: int main() { try { imaps conn("imap.126.com", 993); // modify username/password to use real credentials std::cout << 1 << std::endl; conn.authenticate("[email protected]", "xxxx", imaps::auth_method_t::LOGIN); std::cout << 2 << std::endl; imaps::mailbox_folder fld = conn.list_folders(list()); print_folders(0, fld); conn.select("TEST"); std::cout << 3 << std::endl; list messages; listimaps::search_condition_t conds; conds.push_back(imaps::search_condition_t(imaps::search_condition_t::ALL)); conn.search(conds, messages, true); std::cout << 4 << std::endl; for_each(messages.begin(), messages.end(), [](unsigned int msg_uid){ cout << msg_uid << endl; }); } catch (imap_error& exc) { cout << exc.what() << endl; } catch (dialog_error& exc) { cout << exc.what() << endl; }

return EXIT_SUCCESS;

}

我在网上搜了一下,发现python模块imapclient在登陆126邮箱之前需要调用client.id_(parameters={"name": "dwn_mail", "version": "1.0"}), 不知道mailio怎么做到

shgli avatar Jul 08 '24 04:07 shgli

Hello, what is the name of the folder? Is it in the Latin alphabet?

karastojko avatar Jul 08 '24 19:07 karastojko

the folder name is ZT_AFZ, it in Latin alphabet,

shgli avatar Jul 09 '24 00:07 shgli

Let me try it with my own test.

karastojko avatar Jul 09 '24 13:07 karastojko

There is nothing wrong with such name. What is the full directory path? I see you are selecting the TEST directory. This message can be thrown in case the directory path is wrong. The 126 provider has only the Chinese version or it can be switched to English?

karastojko avatar Jul 09 '24 19:07 karastojko

I changed the folder name from 'ZT_AFZ' to 'TEST' when paste.This issue is caused by 126 server, when I using imapclient (a python module) do the same thing, and got a similar error, after search google, the stack overflow told me that I need client.id_(parameters={"name": "dwn_mail", "version": "1.0"}) before client.login. so I want do the same thing in mailio

shgli avatar Jul 12 '24 13:07 shgli

So, you get the same error with Python?

karastojko avatar Jul 15 '24 19:07 karastojko

if no client.id_(parameters={"name": "dwn_mail", "version": "1.0"}), python error: imaplib.error: select failed: SELECT Unsafe Login. Please contact [email protected] for help

shgli avatar Jul 16 '24 14:07 shgli

Can you please copy here the minimal reproducible example in Python, so I could try it?

karastojko avatar Jul 22 '24 19:07 karastojko

import os import sys import email import mimetypes from imapclient import IMAPClient import datetime

if 3 != len(sys.argv): print(f'usage:{os.path.basename(sys.argv[0])} save_pth from_date') sys.exit(0)

save_dir, since_date=sys.argv[1:] user='[email protected]' password='xx' host='imap.126.com'

since_date = int(since_date) since_year = since_date//10000 since_mon = since_date%10000//100 since_day = since_date%100 since_date = datetime.date(since_year, since_mon, since_day) server = IMAPClient(host, use_uid=True) #server.id_(parameters={"name": "dwn_mail", "version": "1.0"}) server.login(user, password) selected_info = server.select_folder('ZT_AFZ') messages = server.search([b'SINCE', since_date])

shgli avatar Jul 26 '24 12:07 shgli