Salve, vorrei creare un programmino che mi permette di inviare una mail ma ho il seguente problema:
ho provato ad utilizzare il server di email.it -->smtp.email.it
220 smtp-out2.email.it
HELO <nome del mio PC>
250 smtp-out2.email.it
MAIL FROM: prova
501 Bad address syntax
RCPT TO: pippo@apweb.it
503 Error: need MAIL command
DATA
503 No sender.
.
502 Error: command not implemented
Il codice utilizzato è il seguente:
Grazie a tutticodice:void clickBottoneInvia(ActionEvent e) { try { Socket s = new Socket("smtp.email.it", 25); out = new PrintWriter(s.getOutputStream()); in = new BufferedReader(new InputStreamReader (s.getInputStream())); String HostName = InetAddress.getLocalHost().getHostName(); send(null); send("HELO " + HostName); //TextMittente --> contiene l'indirizzo mittente (nell'esempio prova) send("MAIL FROM: " + TextMittente.getText()); //TextDestinatario --> contiene l'indirizzo destinatario(nell'esempio pippo@apweb.it) send("RCPT TO: " + TextDestinatario.getText()); send("DATA"); out.println(TextMessaggio.getText()); send("."); s.close(); } catch(IOException ex) { System.out.print(ex); } } public void send (String s) throws IOException { if (s != null) { System.out.println(s); out.println(s); out.flush(); } String line = in.readLine(); if (line!= null) System.out.println(line); }