gpt4 book ai didi

java - "Sending the email to the following server failed : webmail.company.com:465"

转载 作者:行者123 更新时间:2023-12-04 04:54:49 25 4
gpt4 key购买 nike

我使用此代码发送电子邮件

 Email email = new SimpleEmail();
email.setDebug(true);
email.setHostName("webmail.company.com");
email.setSmtpPort(587);

email.setAuthenticator(new DefaultAuthenticator("username@company.com", "*****"));
email.setSSLOnConnect(true);
try {
email.setFrom("username@company.com");

email.setSubject("TestMail");

email.setMsg("Hi "+receiver.getSex()+" "+receiver.getName()+" "+editorBean.getValue());

email.addTo(receiver.getEmail());
email.send();
} catch (EmailException ex) {
Logger.getLogger(PersonBean.class.getName()).log(Level.SEVERE, null, ex);
result += "exptions :" + ex.getMessage();
return result;
}

我认为 smtp 端口没有改变
“将电子邮件发送到以下服务器失败:webmail.company.com:465”
有什么问题?

最佳答案

您需要使用 setSslSmtpPort(String) 而不是 setSmtpPort(int)因为您正在使用 SSL 进行连接。

关于java - "Sending the email to the following server failed : webmail.company.com:465",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16898842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com