Java 如何查找特定SMTP.host的SMTP端口?
如何找到特定smtp主机的smtp端口Java 如何查找特定SMTP.host的SMTP端口?,java,smtp,Java,Smtp,如何找到特定smtp主机的smtp端口 import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAd
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class SendMailTLS {
public static void main(String[] args) {
final String username = "anthony.savarimut@slingmedia.com";
final String password = "test";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "mail.echostar.com");
props.put("mail.smtp.port", "9000");
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("AnthonyRajS@antony.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("antoalphi@gmail.com"));
message.setSubject("Testing Subject");
message.setText("Dear Mail Crawler,"
+ "\n\n No spam to my email, please!");
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
}
是我的代码但它引发了这个异常
Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset
at samples.SendMailTLS.main(SendMailTLS.java:47)
Caused by: javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2153)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1912)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at samples.SendMailTLS.main(SendMailTLS.java:42)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:89)
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2131)
我确信这会给港口带来问题。请帮我做这件事
问候
TonySMTP的默认端口为25:
我建议您与邮件服务器管理员联系。SMTP的默认端口为25:
我建议您与邮件服务器管理员联系。向管理员询问端口号。在尝试2544587并多次失败之后。我的管理员给了我80作为端口号 向管理员询问端口号。在尝试2544587并多次失败之后。我的管理员给了我80作为端口号 如果您知道要连接的主机,那么还应该知道端口。否则就好比知道某人住在哪条街上,却不知道门牌号。你试过25号和50号吗?这些是一些最常见的SMTP端口。端口50:无法连接到SMTP主机:mail.echostar.com,端口:50;端口25:服务器和客户端都不支持身份验证机制如果您知道要连接的主机,那么您也应该知道该端口。否则就好比知道某人住在哪条街上,却不知道门牌号。你试过25号和50号吗?这些是一些最常见的SMTP端口。端口50:无法连接到SMTP主机:mail.echostar.com,端口:50;端口25:服务器和客户端都不支持身份验证机制,但是否有其他方法可以找到端口号?端口扫描。通常被认为是不礼貌的你为什么不想和管理员说话?这是正确的答案。有帮助,但是有没有其他方法可以找到端口号?端口扫描。通常被认为是不礼貌的你为什么不想和管理员说话?这是正确的答案。