Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Java SMTP client

[es] :: Java :: Java SMTP client

[ Pregleda: 3421 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

sergio77
Beograd

Član broj: 66899
Poruke: 74
212.200.121.*



Profil

icon Java SMTP client27.03.2006. u 21:04 - pre 203 meseci
Moze li neko da mi pomogne u resavanju ovog problema treba da dopunim kod u Javi za slanje maila preko SMTP-a.
SMTPConnection.java

This is the code for the SMTPConncetion class that you will need to complete. The code for the other three classes is provided on this page.

import java.net.*;
import java.io.*;
import java.util.*;

/**
* Open an SMTP connection to a mailserver and send one mail.
*
*/
public class SMTPConnection {
/* The socket to the server */
private Socket connection;

/* Streams for reading and writing the socket */
private BufferedReader fromServer;
private DataOutputStream toServer;

private static final int SMTP_PORT = 25;
private static final String CRLF = "\r\n";

/* Are we connected? Used in close() to determine what to do. */
private boolean isConnected = false;

/* Create an SMTPConnection object. Create the socket and the
associated streams. Initialize SMTP connection. */
public SMTPConnection(Envelope envelope) throws IOException {
// connection = /* Fill in */;
fromServer = /* Fill in */;
toServer = /* Fill in */;

/* Fill in */
/* Read a line from server and check that the reply code is 220.
If not, throw an IOException. */
/* Fill in */

/* SMTP handshake. We need the name of the local machine.
Send the appropriate SMTP handshake command. */
String localhost = /* Fill in */;
sendCommand( /* Fill in */ );

isConnected = true;
}

/* Send the message. Write the correct SMTP-commands in the
correct order. No checking for errors, just throw them to the
caller. */
public void send(Envelope envelope) throws IOException {
/* Fill in */
/* Send all the necessary commands to send a message. Call
sendCommand() to do the dirty work. Do _not_ catch the
exception thrown from sendCommand(). */
/* Fill in */
}

/* Close the connection. First, terminate on SMTP level, then
close the socket. */
public void close() {
isConnected = false;
try {
sendCommand( /* Fill in */ );
// connection.close();
} catch (IOException e) {
System.out.println("Unable to close connection: " + e);
isConnected = true;
}
}

/* Send an SMTP command to the server. Check that the reply code is
what is is supposed to be according to RFC 821. */
private void sendCommand(String command, int rc) throws IOException {
/* Fill in */
/* Write command to server and read reply from server. */
/* Fill in */

/* Fill in */
/* Check that the server's reply code is the same as the parameter
rc. If not, throw an IOException. */
/* Fill in */
}

/* Parse the reply line from the server. Returns the reply code. */
private int parseReply(String reply) {
/* Fill in */
}

/* Destructor. Closes the connection if something bad happens. */
protected void finalize() throws Throwable {
if(isConnected) {
close();
}
super.finalize();
}
}
 
Odgovor na temu

Toni
Dorćol, Beograd

SuperModerator
Član broj: 15
Poruke: 655
..njuel-bg.customer.sbb.co.yu.

Jabber: toni@elitesecurity.org
ICQ: 16451419
Sajt: egoideas.com


Profil

icon Re: Java SMTP client28.03.2006. u 20:56 - pre 203 meseci
ccc tezak ovaj nas fon :-)
Jel potpis treba pisanim ili
štampanim slovima?

___________________________________
______
[url=http://www.dizajnzona.com/foru
ms/]dizajnzona.com[/url]
[url=http://www.netizenfaction.com/
]netizenfaction.com[/url]
egoideas.
com

levodesn
o.com
 
Odgovor na temu

sergio77
Beograd

Član broj: 66899
Poruke: 74
212.200.121.*



Profil

icon Re: Java SMTP client28.03.2006. u 21:03 - pre 203 meseci
Heheh
ima se dosta obaveza, PIS jos i po neki ispit u aprilu i eto ti.
 
Odgovor na temu

Toni
Dorćol, Beograd

SuperModerator
Član broj: 15
Poruke: 655
..njuel-bg.customer.sbb.co.yu.

Jabber: toni@elitesecurity.org
ICQ: 16451419
Sajt: egoideas.com


Profil

icon Re: Java SMTP client31.03.2006. u 22:09 - pre 203 meseci
trebalo bi da stavis i ostale java fajlove koji su potrebi za aplikaciju
Jel potpis treba pisanim ili
štampanim slovima?

___________________________________
______
[url=http://www.dizajnzona.com/foru
ms/]dizajnzona.com[/url]
[url=http://www.netizenfaction.com/
]netizenfaction.com[/url]
egoideas.
com

levodesn
o.com
 
Odgovor na temu

[es] :: Java :: Java SMTP client

[ Pregleda: 3421 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.