• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Java Mail Server

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi EveryOne,
I want to make a mail server using javamail api.
I am able to send the mail but not able to recieve. I have gone through documents of javamail api, there I am getting imap hostname. What is this imap hostname? the overall need is how to recieve message, what are the things required for this & to which the classpath should be setted. please send me the code of this if possible.
i have in my system:
javamail_api1.2,
jaf1.0.1
please specify if any thing required more.
thank you
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java Mail questions should really be asked in the "Other Java APIs" forum. You are much more likely to get a sensible answer there, so I've moved this thread for you.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Extract your jar files ie, activation.jar & mail.jar present in your jaf1.0.1 & javamail1.2 packages.
A javax folder will be created in your weblogic\classes folder. set your classpath to include the weblogic\classes folder
And for your info. Imap hostname means the name of your computer where your mailserver is present.Your mailserver should be supporting the imap protocol. Imap protocol is the protocol available for reading of messages
[This message has been edited by sanjuantony (edited April 16, 2001).]
 
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
'sanjuantony'
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can either use IMAP or POP to receive the mails. Eg.
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;

public class POP3Client {
public static void main(String[] args) {

Properties props = new Properties();
// host name here is the POP or IMAP server.
String host = "";
//here u can use the username to access the Inbox
String username = "";
String password = "";
//provider can either be POP or IMAP
String provider = "pop3";
try {
// Connect to the POP3 server
Session session = Session.getDefaultInstance(props, null);
System.out.println("I am after Session creation");
Store store = session.getStore(provider);
System.out.println("I am after getting the Store");
store.connect(host, username, password);

// Open the folder
Folder inbox = store.getFolder("INBOX");
if (inbox == null) {
System.out.println("No INBOX");
System.exit(1);
}
inbox.open(Folder.READ_ONLY);

// Get the messages from the server
Message[] messages = inbox.getMessages();
for (int i = 0; i < messages.length; i++) {
System.out.println("------------ Message " + (i+1)
+ " ------------");
messages[i].writeTo(System.out);
}
// Close the connection
// but don't remove the messages from the server
inbox.close(false);
store.close();

}
catch (Exception e) {
e.printStackTrace();
}

}
public static void printMessage(Message m) throws Exception {
// Print the message header
Address[] from = m.getFrom();
if (from != null) {
for (int i = 0; i < from.length; i++) {
System.out.println("From: " + from[i]);
}
}

Address[] to = m.getRecipients(Message.RecipientType.TO);
if (to != null) {
for (int i = 0; i < to.length; i++) {
System.out.println("To: " + to[i]);
}
}

String subject = m.getSubject();
if (subject != null) {
System.out.println("Subject: " + subject);
}

Date d = m.getSentDate();
if (d != null) {
System.out.println("Date: " + d);
}
// Print a blank line to separate the header from the body
System.out.println();
// Print the message body
Object content = m.getContent();
if (content instanceof String) {
System.out.println(content);
}
else if (content instanceof InputStream) {
InputStream in = (InputStream) content;
int c;
while ((c = in.read()) != -1) System.out.write(c);
}
else {
System.out.println("Unrecognized Content Type");
}

}
}
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Subramaniam Krishnan,
Tell me how to send msg using java mail API. I tried it by demo program given with java mail api as explained at http://developer.java.sun.com/developer/onlineTraining/JavaMail/exercises/MailSetup/help.html But unable to do so. It is giving the error of pop authentication. I am unable to understand where to give the password. Please help me out.
Regards

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello anup!
have u extracted javamail1.2.1. in that docs.. try running msgsendexample.java to run this u should have a mailserver configured to any system in network..
the host name u will be giving here is the name of the server
to which the mailserver is configured.
..
if u r running javaMailservlet.java
then here
imaphostname : mailserver configured sytem name
name: login name of the outlook express or any thing configured in ur system
password.: password ur inbox in outlookexpress
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic