I am trying to fetch mails from gmail and i am able to fetch the mails but whenever i connect to VPN i.e my office VPN i am getting exception
Code:
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
properties.load(input);
properties.put( "mail.imap.ssl.socketFactory", sf);
session = Session.getInstance(properties);
// connects to the message store
store = session.getStore("imap");
store.connect(properties.getProperty("username"), properties.getProperty("password"));
folderInbox = store.getFolder("INBOX");
folderInbox.open(Folder.READ_ONLY);
Properties file:
mail.imap.host=imap.gmail.com
mail.imap.socketFactory.port=993
mail.imap.socketFactory.class=javax.net.ssl.SSLSocketFactory
mail.imap.socketFactory.fallback=false
mail.imap.ssl.enable=true
mail.imap.auth=true
mail.imap.port=993
username=example.gmail.com
password=**********
Is there anyother way to automate email receive functionality. The end goal I am trying to achive is to test the email sent by the Application is received by user or not and also validate the data it contains
Aucun commentaire:
Enregistrer un commentaire