SMTP 服务器是否有可接受的语法? (以及如何解析它)
我见过这样的事情:
user:password@smtpserver:port
过去,但我不确定某个库是否解析它来构建属性来创建会话,或者是否存在某种可接受的格式。
I've seen things like:
user:password@smtpserver:port
In the past, but I'm not sure if the some library parsed that to build a properties to create a session or is there some sort of accepted format.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 URI 来指定网络资源(例如 SMTP 服务器)可能是最接近“接受”格式的东西,SMTP URI 类似于 smtp://user:[email protected]:port 或可能只是 smtp://example.com 。您可以使用通用 URI 解析库来提取各种组件。
还有一个 的旧 RFC 草案SMTP URL
Using an URI for specifying a network resource, such as an SMTP server is probably the cloeset thing to a "accepted" format you'd see, an SMTP URI, would be something like smtp://user:[email protected]:port or perhaps just smtp://example.com . You'd use a generic URI parsing library to extract the various components.
There's also an old RFC draft for SMTP URLs
虽然有 SMTP URL 方案,但我有从未见过有人使用它。实际上,大多数应用程序都提供四个单独的字段:主机、端口、用户名和密码。但是,如果您确实需要将这四个组件放入一个字符串中,那么您提供的示例可能是此类内容的最著名格式。
While there is a SMTP URL Scheme, I have never seen anyone use it. In practice, most applications provide four separate fields for host, port, user name and password. But if you really need to put those four components into a single string, the example you provided is probably the best-known format for something like this.
我认为这会起作用。
我想添加作为答案,我如何使用 java.net.URI 类从该 URI 获取信息。
输出
I think that would work.
I would like to add as answer, how I'm using java.net.URI class get information from that URI.
Output
正在配置节点应用程序,但很难获得它。
smtp://username:password@smtphost:port
有趣的是我的密码有一个“@”,所以它假设主机名已经开始。
用户名还有一个“@”服务器,但它很好,因为它由冒号“:”分隔,
希望这有帮助。
干杯
Was configuring node app and had a hard time getting it.
smtp://username:password@smtphost:port
The funny part was my password was having an '@' so it was presuming the hostname has started.
The username also had an '@' server but it was good as it was separated by the colon ":"
Hope this helps.
Cheers