This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Send email using IMAP , what changes my code need to do authentication ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Send email using IMAP , what changes my code need to do authentication ?" Watch "Send email using IMAP , what changes my code need to do authentication ?" New topic
Author

Send email using IMAP , what changes my code need to do authentication ?

raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 551
Hi
thank you for reading my post
here is my code to send email using SMTP , now i want to change this code to send email using IMAP and it should be authenticated , does any one know which changes i should introduce in this code ?

thanks
siva kumar
Ranch Hand

Joined: May 02, 2004
Posts: 120
Hi,

For reading messages from IMAP server use the following code-snippet below

Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("IMAP");
store.connect(host, username, password);
Folder inbox = store.getFolder("INBOX");
inbox.open(Folder.READ_WRITE);
Message[] messages = inbox.getMessages( );

If you need to use POP3 protocol then change the code

Store store = session.getStore("POP3");

Please note I think folder concept does not apply to POP3 protocols

And further more as far as I know one does not need to provide user-name and password for sending mails, Auth info is gendrally required for reading mails, but some mail servers may have security restrictions which may require auth info even for sending mails
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Sivaram's answer about how to read messages from IMAP and POP3 servers is certainly correct, but it fails to mention how to send messages using those servers.

That's because you can't send messages using those servers.
 
jQuery in Action, 2nd edition
 
subject: Send email using IMAP , what changes my code need to do authentication ?
 
Similar Threads
Getting exception in sending Email from Servlet
Need Information about sending email Please
javamail.providers
Javamail: Problem sending attachments
Mail sending program