JavaMail 中的 props.put("mail.smtp.host", host) 有什么作用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2957643/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 14:55:36  来源:igfitidea点击:

What does props.put("mail.smtp.host", host) in JavaMail do?

javajavamail

提问by simplyblue

Can anybody explain me what this line means in JavaMail API?

谁能解释一下这行在 JavaMail API 中的含义?

props.put("mail.smtp.host", host);

It is used to setup a mail server, but I don't understand it.

它用于设置邮件服务器,但我不明白。

采纳答案by bmargulies

The String variable hostcontains the DNS name of a server that accepts connections on port 25 for SMTP. Adding this property to the props collection, which is in turn passed into Javamail, tells Javamail what host to send the mail to, initially.

String 变量host包含接受端口 25 上的 SMTP 连接的服务器的 DNS 名称。将此属性添加到 props 集合,该集合又被传递到 Javamail,告诉 Javamail 最初将邮件发送到哪个主机。

You might also see something that helps in this answer.

您可能还会看到有助于此答案的内容

回答by GustyWind

This value helps Javamail to understand to which server it has to hit for DNS name. Its ususally through a port opened( default 25).

该值有助于 Javamail 了解它必须为 DNS 名称访问哪个服务器。它通常通过打开的端口(默认为 25)。