Witam, mój problem polega na tym, że nie wiedzieć czemu funkcja nie wysyła maila (kod jest podobny do tego zawartego w CORE JAVA 2). chciałbym aby wysyłała ona maile, na podany mój adres. Może chodzi o to że w konstruktorze Socket`a podaje błędnego stringa?? a może w aplecie nie ma prawa działaćtakie coś??
public void send(String a) throws IOException
{out.print(a.replaceAll("\n","\r\n" ));
out.print("\r\n");
out.flush();
}
public void sendMail(String jeden, String dwa){
try{
String hostName= InetAddress.getLocalHost().getHostName();
Socket s= new Socket("[email protected]", 25);
InputStream inStream = s.getInputStream();
OutputStream outStream = s.getOutputStream();
in = new Scanner(inStream);
out = new PrintWriter(outStream, true);
receive();
send("HELO "+hostName);
receive();
send("MAIL FROM:<"+"[email protected]"+">");
receive();
send("RCPT TO:<"+"[email protected]"+">");
receive();
send("DATA");
receive();
send(jeden);
receive();
send(dwa);
send(".");
receive();
send("QUIT");
s.close();
} catch(IOException e)
{}
}