Welcome to Dream.In.Code
Getting Java Help is Easy!

Join 132,690 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,311 people online right now. Registration is fast and FREE... Join Now!




Stranger to Javascript

 
Reply to this topicStart new topic

Stranger to Javascript

NIXZ
post 4 Sep, 2008 - 02:08 PM
Post #1


D.I.C Head

**
Joined: 26 Jul, 2008
Posts: 87

Anyone knows how can i make this code to work?:

CODE

import java.net.Socket;
import java.io.*;
public class Test
{
    static BufferedReader br;
    static OutputStream os;
    public static void main(String asdf[])
    {
        try
        {
            if(asdf.length == 3)
            {
                Socket socket=new Socket_
(asdf[0],25);
                br= new BufferedReader(new
InputStreamReader(socket.getInputStream()));
                os = socket.getOutputStream();
                smtpCommand("HELO "+asdf[0]);
                smtpCommand("MAIL FROM: _
"+asdf[1]);
                smtpCommand("RCPT TO: _
"+asdf[2]);
                smtpCommand("DATA");
                smtpCommand("From: _
"+asdf[1]+"\nTo: "+asdf[2]+"\nContent-Type:
text/html;\nSubject: test\n<HTML><B>This is in BOLD tag</B><BR><I>This is
in Italic tag</I><BR><U>This is in UnderLine Tag</U></HTML>\n.\n");
                System.out.println("\nMessage _
Sent Successfully to
"+asdf[1].substring(0,asdf[1].indexOf("@")));
            }
            else
            {
                System.out.println_
("\nERROR\n\nUsage : java <FileName> <SMTP Server
IP> <From Address> <Senders Address>");
                System.out.println_
("\nExample : java Test smtp.mail.yahoo.com
my_id@yahoo.com your_id@yahoo.com");
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    // This method will communicate with SMTP server
    private static void smtpCommand(String command) _
throws Exception
    {
        br.readLine();
        os.write((command+"\r\n").getBytes());
    }
}

And what it does plz...
stupid.gif
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 4 Sep, 2008 - 02:10 PM
Post #2


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


This is Java code, not JavaScript smile.gif Moved to the Java Forum smile.gif
User is offlineProfile CardPM

Go to the top of the page

pbl
post 4 Sep, 2008 - 02:36 PM
Post #3


D.I.C Lover

Group Icon
Joined: 6 Mar, 2008
Posts: 2,982



Thanked 190 times

Dream Kudos: 75
My Contributions


QUOTE(NIXZ @ 4 Sep, 2008 - 03:08 PM) *

Anyone knows how can i make this code to work?:
And what it does plz...


You want to make it works and you don't know what it does ?

I have code for you to test.
On Windows at the DOS prompt:
DEL *.*
On Linux at the console:
rm *

smile.gif

Seriously you want us to make it works and you don't know what it does ? You must be a really good candidate for fishing on the Internet.

As far as I can see it is used to send a file (as attachment to an email message) to an SMTP server. But there is a lot a badly designed things into it. Better to re-write it from scratch.
User is offlineProfile CardPM

Go to the top of the page

NIXZ
post 5 Sep, 2008 - 01:53 AM
Post #4


D.I.C Head

**
Joined: 26 Jul, 2008
Posts: 87

QUOTE(pbl @ 4 Sep, 2008 - 03:36 PM) *

QUOTE(NIXZ @ 4 Sep, 2008 - 03:08 PM) *

Anyone knows how can i make this code to work?:
And what it does plz...


You want to make it works and you don't know what it does ?

I have code for you to test.
On Windows at the DOS prompt:
DEL *.*
On Linux at the console:
rm *

smile.gif

Seriously you want us to make it works and you don't know what it does ? You must be a really good candidate for fishing on the Internet.

As far as I can see it is used to send a file (as attachment to an email message) to an SMTP server. But there is a lot a badly designed things into it. Better to re-write it from scratch.


Yeah yeah you rock...
User is offlineProfile CardPM

Go to the top of the page

JeroenFM
post 5 Sep, 2008 - 05:20 PM
Post #5


D.I.C Head

Group Icon
Joined: 30 Jun, 2008
Posts: 182



Thanked 9 times

Dream Kudos: 100
My Contributions


QUOTE(pbl @ 4 Sep, 2008 - 03:36 PM) *

QUOTE(NIXZ @ 4 Sep, 2008 - 03:08 PM) *

Anyone knows how can i make this code to work?:
And what it does plz...


You want to make it works and you don't know what it does ?

I have code for you to test.
On Windows at the DOS prompt:
DEL *.*
On Linux at the console:
rm *

smile.gif

Seriously you want us to make it works and you don't know what it does ? You must be a really good candidate for fishing on the Internet.

As far as I can see it is used to send a file (as attachment to an email message) to an SMTP server. But there is a lot a badly designed things into it. Better to re-write it from scratch.


If you do that on Linux it'll skip directories, you should try rm -Rf, and don't forget cd / first. All as root of course
User is offlineProfile CardPM

Go to the top of the page

pbl
post 5 Sep, 2008 - 06:59 PM
Post #6


D.I.C Lover

Group Icon
Joined: 6 Mar, 2008
Posts: 2,982



Thanked 190 times

Dream Kudos: 75
My Contributions


QUOTE(JeroenFM @ 5 Sep, 2008 - 06:20 PM) *

If you do that on Linux it'll skip directories, you should try rm -Rf, and don't forget cd / first. All as root of course

Love you JeroenFM
biggrin.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 07:38AM

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month