Ragazzi sto cecando di creare un messaggio che invia un e-mail in java questo è il codice ...ma nn so perche nn funziona forse è l'autetificazione vi posto il codice potreste darmi una mano a renderlo funzionate.....vi rigrazio
import java.util.*;
import java.net.*;
import java.io.*;
public class InvioMail
{
static BufferedReader in;
static PrintWriter out;
static String server="smtp.fastwebnet.it";
static String mittente="aspire1982@hotmail.it";
static String destinatario="aspire1982@hotmail.it";
static String messaggio="ciao";
public static void main(String[] args)
{
try
{
Socket s = new Socket(server, 25);
out = new PrintWriter(s.getOutputStream());
in = new BufferedReader(new InputStreamReader(s.getInputStream()));
String hostName = InetAddress.getLocalHost().getHostName();
receive();
send("HELO "+ hostName);
receive();
send("MAIL FROM: <"+ mittente + ">");
receive();
send("RCPT TO: <" + destinatario + ">");
receive();
send("DATA");
receive();
StringTokenizer tokenizer = new StringTokenizer(messaggio, "\n");
while (tokenizer.hasMoreTokens())
send(tokenizer.nextToken());
send(".");
receive();
s.close();
}
catch (IOException exception)
{
System.out.println("Error: " + exception);
}
}
public static void send(String s) throws IOException
{
System.out.println(s);
System.out.println("\n");
out.print(s);
out.print("\r\n");
out.flush();
}
public static void receive() throws IOException
{
String line = in.readLine();
if (line != null)
{
System.out.println(line);
System.out.println("\n");
}
}
}
e cmq il tipo di errore che da è
init:
deps-jar:
compile-single:
run-single:
220 aa012msr.fastwebnet.it ESMTP Service ready
HELO acer-2d60536d59
250 aa012msr.fastwebnet.it
MAIL FROM: <aspire1982@hotmail.it>
250 MAIL FROM:<aspire1982@hotmail.it> OK
RCPT TO: <aspire1982@hotmail.it>
250 RCPT TO:<aspire1982@hotmail.it> OK
DATA
354 Start mail input; end with <CRLF>.<CRLF>
ciao
.
554 Message refused

Rispondi quotando