I don't know how you can say that JavaMail is easy
- take a look at that :
> that is required to send a message:
SendMailToRecipient smtr = new
SendMailToRecipient(toAddress,fromAddress,subject,body);
a little bit easy ?
Class goes here (not ideal implementation but bring
an idea how smtp works) :
------------------------------------------------------
import java.io.*;
import java.util.*;
import java.net.*;
public class SendMailToRecipient extends Thread {
String mailTo, mailFrom, subject, body;
public SendMailToRecipient( String to, String from,
String subject, String body){
mailTo = to;
mailFrom = from;
this.subject = subject;
this.body = body;
this.start();
}
public void run() {
String in = "";
Socket socket = null;
PrintWriter pw = null;
BufferedReader br = null;
try{
socket = new Socket
(c.mailServerIP,25);
pw = new PrintWriter
(socket.getOutputStream());
br = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
in = br.readLine();
}
catch(Exception e){
}
sayToSMTP("mail from:<"+mailFrom+">",pw,br);
sayToSMTP("rcpt to:<"+mailTo+">",pw,br);
sayToSMTP("data",pw,br);
pw.println("From: "+mailFrom);
pw.println("To:"+mailTo);
pw.println("Subject: "+subject);
StringTokenizer st = new StringTokenizer((new
Date()).toString());
String day = st.nextToken();
String month = st.nextToken();
String chislo = st.nextToken();
String time = st.nextToken();
String delta = st.nextToken();
String year = st.nextToken();
pw.println("Date: "+day+", "+chislo+" "+month+"
"+year+" "+time+" "+delta);
pw.println(body);
pw.println(".");
pw.flush();
try{
in = br.readLine();
pw.close();
br.close();
}
catch(Exception e){
}
}
static boolean sayToSMTP(String s, PrintWriter pw,
BufferedReader br){
try{
pw.println(s);
pw.flush();
String in = br.readLine();
return true;
}
catch(Exception e){
return false;
}
}
-------------------------------------------------------
---Chris Pratt <[EMAIL PROTECTED]> wrote:
>
> I don't know how you can say that JavaMail is too
difficult, this is all
> that is required to send a message:
>
> try {
> MimeMessage msg = new MimeMessage(session);
> Address[] addr =
InternetAddress.parse("[EMAIL PROTECTED]");
> msg.addFrom(addr);
>
msg.addRecipients(Message.RecipientType.TO,addr);
> msg.setReplyTo(addr);
> msg.setSubject("This is a test message");
> msg.setSentDate(new Date());
> msg.setText("Testing, 1, 2, 3, Testing");
> Transport.send(msg);
> } catch(MessagingException x) {
> System.err.println("Exception while Sending
Message");
> x.printStackTrace(System.err);
> }
>
> (*Chris*)
>
> ----- Original Message -----
> From: Won, Taewoong <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, July 12, 1999 11:54 PM
> Subject: Servlet
>
>
> > My servlet need to send e-mail message via remote
SMTP servler. The
> environment
> > is Solaris 2.6, ServletExec 2.0, Netscape
Enterprise Server with Sun JDK
> 1.2
> > VM. At first I looked into JavaMail API, but it
is too complicated for our
> > simple needs. Are there any other simple
SMTP-repackage available that I
> can
> > use with minimum modification?
> >
> > Won, Taewoong
> > [EMAIL PROTECTED]
> >
> >
>
___________________________________________________________________________
> > To unsubscribe, send email to
[EMAIL PROTECTED] and include in the
> body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives:
http://archives.java.sun.com/archives/servlet-interest.html
> > Resources:
http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help:
http://www.lsoft.com/manuals/user/user.html
> >
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED]
and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives:
http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help:
http://www.lsoft.com/manuals/user/user.html
>
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html