java - JavaMail API Error (javax.mail.NoSuchProviderException: invalid provider) -


I am trying to create a program using the JavaMail API, however, I receive the following error message.

  javax.mail.NoSuchProviderException: invalid provider at javax.mail. Jess.mail.Session.getTransport (session.Java: 738) at javax.mail.Session.getTransport (session.java: 682) at javax.mail Session at EmailAutoResponder2.main .get Transport (session .Java: 662)  

I could not solve it by reading online, because all their solutions are still given to me the same message

Here is the Java code:

  import java.util. *; Import javax.mail *; Import javax.mail.internet. *; Public Square EmailAutoResponder2 {public static zero main (string [] args) {string to = "username@videotron.ca"; String = "username@videotron.ca"; Properties Properties = System.getProperties (); Properties.setProperty ("mail.store.protocol", "imaps"); Sessions Session 1 = Session. Gate Instance (Properties); // If received by specific user, send specific feedback property property = new property (); Props.put ("mail.imap.auth", "true"); Props.put ("mail.imap.starttls.enable", "true"); Props.put ("mail.imap.host", "imap.videotron.ca"); Props.put ("mail.imap.port", "143"); Session session 2 = session. Gate instant (support, new authenticator) {Secure PasswordAction getPasswordAuthentication ()} New passwordEctication ("username@videotron.ca", "password");}}); Try {store store = session2.getStore ("imap"); Store.connect ("imap.videotron.ca", "username@videotron.ca", "password"); Folder fldr = store.getFolder ("Inbox"); Fldr.open (Folder.READ_ONLY); Message message [] = fldr.getMessages (); For (Int i = 0; I & lt; msgs.length; i ++) {System.out.println (Internet address.stosting (msg [i] .getFrom ())); If (Internet address .tosting (msg) [i] .getFrom ()). Start ("name")) {mime message message = new mime message (session 1); Message.setFrom (new Internet address (from)); Message.addRecipient (Message.RecipientType.TO, new Internet address); Message.setSubject ("subject"); Message.setText ("message"); String protocol = "ipad"; Props.put ("Mail." + Protocol + ".auth", "true"); Transport T = session2.getTransport ("imap"); Try {t.connect ("username@videotron.ca", "password"); T.sendMessage (Message, message.getAllRecipients ()); } Finally {t. Close (); }}}} Catch (Messaging Exception Makes) {mex.printStackTrace (); } Catch (exception exc) {}}}  

thanks!

You are connecting to a local host to send messages. Do you have a mail server running on your local machine? Maybe not You must set up the mail smtp.host property. You may also need to provide usernames and passwords for your mail server; See.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -