i have code login smtp.gmail.com using sslsocket send email have problem when try content response server,it stuck in while loop(i guess) bufferedreader.hope can me.i trying type "ehlo smtp.gmail.com" , server response stuck after then.thanks lot.this code :
` package mailclient;
import com.sun.prism.pixelformat; import java.io.bufferedreader; import java.io.bufferedwriter; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.io.outputstreamwriter; import java.io.printwriter; import java.net.socket; import java.util.scanner; import java.util.logging.level; import java.util.logging.logger; import javax.net.ssl.sslsocket; import javax.net.ssl.sslsocketfactory; import javax.xml.bind.datatypeconverter; public class mailclient { public static void main(string[] args){ scanner scan = new scanner(system.in); // todo code application logic here sslsocketfactory sslsocket = (sslsocketfactory)sslsocketfactory.getdefault(); sslsocket s; try { s = (sslsocket) sslsocket.createsocket("smtp.gmail.com",465); bufferedreader input = new bufferedreader(new inputstreamreader(s.getinputstream())); printwriter printwriter = new printwriter(s.getoutputstream(),true); bufferedreader from_user = new bufferedreader(new inputstreamreader(system.in)); string message; while(true){ system.out.println("message server"); message = from_user.readline(); if(message.equals("quit")){ s.close(); break; } printwriter.println(message); string result; system.out.println("reply server"); while((result = input.readline())!=null){ system.out.println(result); } } } catch (ioexception ex) { logger.getlogger(mailclient.class.getname()).log(level.severe, null, ex); } } }
`
Comments
Post a Comment