简体   繁体   English

如何使用Java中的套接字验证SMTP服务器是否正常工作

[英]how to verify if SMTP server is working using socket in java

I want to check if the given SMTP server is working fine by just getting connection and send a hello message and then verify the response code. 我想通过仅获取连接并发送问候消息,然后验证响应代码来检查给定的SMTP服务器是否工作正常。 I don't want to test it by sending email to some address. 我不想通过将电子邮件发送到某个地址来对其进行测试。

I am using java 1.6. 我正在使用Java 1.6。

Please help 请帮忙

Create a socket Socket s = new Socket("addres_of_smtp_server", stmp_port); 创建一个套接字Socket s = new Socket("addres_of_smtp_server", stmp_port);
and then check if the server is alive. 然后检查服务器是否还活着。 Here is the same question in stackoverflow How to check status of an SMTP server from Java? 这是stackoverflow中的相同问题。 如何从Java检查SMTP服务器的状态? . Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM