Set IMAP ID when connect

Hi Team,

When using IMAP add-on, there is a problem with mail.163.com. It always reports NO SELECT Unsafe Login. Please contact kefu@188.com for help, checking official website at
帮助中心_常见问题

it suggested we need to add below code, i.e. need set IMAP ID:

Properties props = new Properties(); 
props.setProperty("mail.store.protocol", "imap"); 
props.setProperty("mail.imap.host", "imap.163.com"); 
props.setProperty("mail.imap.port", "143"); 

HashMap IAM = new HashMap();
// adding IMAP ID info, key-value format, e.g.name, version, vendor, support-email etc.
IAM.put("name","myname");      
IAM.put("version","1.0.0");      
IAM.put("vendor","myclient");      
IAM.put("support-email","testmail@test.com");  
Session session = Session.getInstance(props); 

IMAPStore store = (IMAPStore) session.getStore("imap");
// replace with your account and pwd.
store.connect("testmail@163.com", "password"); 

store.id(IAM);

Reference: https://www.ietf.org/rfc/rfc2971.txt

Please suggest how can we do this?

Hi @hanbing.yin,

It is possible to override the getStore(..) method of the ImapHelper bean and set required id to the connected IMAPStore.
For example :

    @Override
    public IMAPStore getStore(ImapMailBox box) throws MessagingException {
        IMAPStore store = super.getStore(box);

        Map<String, String> IAM = new HashMap<>();
        IAM.put("name", "myname");
        IAM.put("version", "1.0.0");
        IAM.put("vendor", "myclient");
        IAM.put("support-email", "testmail@test.com");

        store.id(IAM);
        return store;
    }

Regards,
Maria.

Thank you! Will try