<legend id='7fhBS'><style id='7fhBS'><dir id='7fhBS'><q id='7fhBS'></q></dir></style></legend>

        <small id='7fhBS'></small><noframes id='7fhBS'>

        <tfoot id='7fhBS'></tfoot>
        • <bdo id='7fhBS'></bdo><ul id='7fhBS'></ul>
        <i id='7fhBS'><tr id='7fhBS'><dt id='7fhBS'><q id='7fhBS'><span id='7fhBS'><b id='7fhBS'><form id='7fhBS'><ins id='7fhBS'></ins><ul id='7fhBS'></ul><sub id='7fhBS'></sub></form><legend id='7fhBS'></legend><bdo id='7fhBS'><pre id='7fhBS'><center id='7fhBS'></center></pre></bdo></b><th id='7fhBS'></th></span></q></dt></tr></i><div id='7fhBS'><tfoot id='7fhBS'></tfoot><dl id='7fhBS'><fieldset id='7fhBS'></fieldset></dl></div>
      1. 使用 JAVA API 查找知道电子邮件地址的 SMTP 主机和端口

        Finding SMTP host and port knowing the e-mail address using JAVA API(使用 JAVA API 查找知道电子邮件地址的 SMTP 主机和端口)

            <bdo id='cTmqT'></bdo><ul id='cTmqT'></ul>

            1. <legend id='cTmqT'><style id='cTmqT'><dir id='cTmqT'><q id='cTmqT'></q></dir></style></legend>
              1. <small id='cTmqT'></small><noframes id='cTmqT'>

                • <i id='cTmqT'><tr id='cTmqT'><dt id='cTmqT'><q id='cTmqT'><span id='cTmqT'><b id='cTmqT'><form id='cTmqT'><ins id='cTmqT'></ins><ul id='cTmqT'></ul><sub id='cTmqT'></sub></form><legend id='cTmqT'></legend><bdo id='cTmqT'><pre id='cTmqT'><center id='cTmqT'></center></pre></bdo></b><th id='cTmqT'></th></span></q></dt></tr></i><div id='cTmqT'><tfoot id='cTmqT'></tfoot><dl id='cTmqT'><fieldset id='cTmqT'></fieldset></dl></div>

                • <tfoot id='cTmqT'></tfoot>
                    <tbody id='cTmqT'></tbody>
                  本文介绍了使用 JAVA API 查找知道电子邮件地址的 SMTP 主机和端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我做了一个简单的应用程序来使用 Java API 发送电子邮件并有一个问题:

                  I made a simple application to send e-mails using Java API and have a question:

                  有什么方法可以找出知道要登录发送电子邮件的人的电子邮件地址的 SMTP 主机吗?还有港口?

                  例如,如果发件人的电子邮件地址是 sender@gmail.com,则 SMTP 主机是 smtp.gmail.com,端口是 465.如果发件人的电子邮件地址是 sender@yahoo.com,则 SMTP主机是 smtp.yahoomail.com 和端口 25.

                  For example, if the sender's e-mail address is sender@gmail.com, the SMTP host is smtp.gmail.com and the port 465. If the sender's e-mail address is sender@yahoo.com, the SMTP host is smtp.yahoomail.com and the port 25.

                  假设我不知道这一点,有没有办法使用 Java API 类找到这些信息?请注意,我是 java 新手 :)

                  Supposing I don't know this, is there any way to find this information using Java API classes? Please note that I'm new to java :)

                  提前致谢,

                  安德烈亚

                  感谢您的回答.我已尝试执行以下操作:

                  Thanks for your answers. I've tried to do the following:

                  public static String getMXRecordsForEmailAddress(String eMailAddress) { 
                            
                      String returnValue = null; 
                      
                      try { 
                          String hostName = getHostNameFromEmailAddress(eMailAddress); 
                          Record[] records = new Lookup(hostName, Type.MX).run();
                  
                          if (records == null) { 
                              throw new RuntimeException("No MX records found for domain " + hostName + ".");
                          }
                           
                          // return first entry (not the best solution) 
                          if (records.length > 0) { 
                              MXRecord mx = (MXRecord) records[0]; 
                              returnValue = mx.getTarget().toString(); 
                          } 
                      } catch (TextParseException e) { 
                          throw new RuntimeException(e); 
                      } 
                           
                      System.out.println("return value = "+returnValue);
                      return returnValue; 
                  } 
                  

                  但是,无论 hostName 的值如何(例如 gmail.com、yahoo.com )Record[] records = new Lookup(hostName, Type.MX).run(); 总是返回 null.

                  But, regardless of the value of hostName (eg. gmail.com, yahoo.com ) Record[] records = new Lookup(hostName, Type.MX).run(); always return null.

                  我很确定我错过了什么,但我不知道是什么.你能帮我解决这个问题吗?你能告诉我我做错了什么吗?

                  I'm pretty sure that I missed something, but I don't know what. Will you please help me with this? Can you tell me what I'm doing wrong?

                  非常感谢,

                  安德烈亚

                  推荐答案

                  不幸的是,没有标准的方法来识别任意电子邮件地址的正确传出 SMTP 服务器,假设您尝试做的是让用户指定一个电子邮件地址/密码,然后使用该帐户发送邮件.

                  Unfortunately, there's no standard way to identify the correct outgoing SMTP server for an arbitrary email address, assuming what you're trying to do is let the user specify an email address/password and then send the mail using that account.

                  这就是为什么电子邮件客户端(例如 Thunderbird、Outlook 等)通常需要用户手动配置传出 SMTP 服务器名称/端口的原因.您可以通过识别一些流行的 ISP(Google、Yahoo 等)并预先配置正确的值来协助该过程,但没有通用的方法可以自动执行此操作.

                  That's why email clients (e.g. Thunderbird, Outlook, etc.) generally require the user to configure the outgoing SMTP server name/port manually. You could assist in that process by recognizing a few popular ISPs (Google, Yahoo, etc.) and pre-configuring the proper values, but there's no general-purpose way to do that automatically.

                  这篇关于使用 JAVA API 查找知道电子邮件地址的 SMTP 主机和端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                      <small id='hCiVU'></small><noframes id='hCiVU'>

                      1. <tfoot id='hCiVU'></tfoot>
                      2. <i id='hCiVU'><tr id='hCiVU'><dt id='hCiVU'><q id='hCiVU'><span id='hCiVU'><b id='hCiVU'><form id='hCiVU'><ins id='hCiVU'></ins><ul id='hCiVU'></ul><sub id='hCiVU'></sub></form><legend id='hCiVU'></legend><bdo id='hCiVU'><pre id='hCiVU'><center id='hCiVU'></center></pre></bdo></b><th id='hCiVU'></th></span></q></dt></tr></i><div id='hCiVU'><tfoot id='hCiVU'></tfoot><dl id='hCiVU'><fieldset id='hCiVU'></fieldset></dl></div>
                          <tbody id='hCiVU'></tbody>
                        <legend id='hCiVU'><style id='hCiVU'><dir id='hCiVU'><q id='hCiVU'></q></dir></style></legend>

                            <bdo id='hCiVU'></bdo><ul id='hCiVU'></ul>