public class SendTest {
public static void main(String[] args) throws IOException {
for(int i=0;i<100;i++){
Socket socket = new Socket("smtp.qq.com", 25);
InputStream inStream = socket.getInputStream();
OutputStream outStream = socket.getOutputStream();
PrintWriter out = new PrintWriter(outStream, true);
Scanner in = new Scanner(inStream);
String hostName = InetAddress.getLocalHost().getHostName();
receive(in);
send("HELO " + hostName, out);
receive(in);
send("AUTH LOGIN",out);
receive(in);
send("MTI0NDI1NDM2NQ==",out);//QQ号Base64加密(纯数字) http://www.bejson.com/enc/base64/ 加密网址
receive(in);
send("Z3Vib3Z0aWlyZnd6amJiZg==",out);//授权码Base64加密
receive(in);
send("MAIL FROM:<QQ号@qq.com>", out);
receive(in);
send("RCPT TO:<QQ号@qq.com>", out);
receive(in);
send("DATA", out);
receive(in);
send("哈哈 你好", out);
send(".", out);
receive(in);
socket.close();
}
}
public static void send(String s,PrintWriter out) {
out.print(s.replaceAll("\n", "\r\n"));
out.print("\r\n");
out.flush();
System.out.println(s);
}
public static void receive(Scanner scanner){
String line = scanner.nextLine();
System.out.println(line);
}
}
java Socket发送QQ邮件
最新推荐文章于 2023-07-08 18:15:16 发布