org.apache.commons.mail.Email.getHostName()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中org.apache.commons.mail.Email.getHostName()方法的一些代码示例,展示了Email.getHostName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Email.getHostName()方法的具体详情如下:
包路径:org.apache.commons.mail.Email
类名称:Email
方法名:getHostName

Email.getHostName介绍

[英]Gets the host name of the SMTP server,
[中]获取SMTP服务器的主机名,

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. * Sends the previously created MimeMessage to the SMTP server.
  3. *
  4. * @return the message id of the underlying MimeMessage
  5. * @throws IllegalArgumentException if the MimeMessage has not been created
  6. * @throws EmailException the sending failed
  7. */
  8. public String sendMimeMessage()
  9. throws EmailException
  10. {
  11. EmailUtils.notNull(this.message, "MimeMessage has not been created yet");
  12. try
  13. {
  14. Transport.send(this.message);
  15. return this.message.getMessageID();
  16. }
  17. catch (final Throwable t)
  18. {
  19. final String msg = "Sending the email to the following server failed : "
  20. + this.getHostName()
  21. + ":"
  22. + this.getSmtpPort();
  23. throw new EmailException(msg, t);
  24. }
  25. }

代码示例来源:origin: br.com.caelum.vraptor/vraptor-simplemail

  1. protected void wrapUpAndSend(Email email) throws EmailException {
  2. LOGGER.debug(String.format(emailLogTemplate(),
  3. email.getSubject(),
  4. email.getFromAddress(),
  5. email.getToAddresses(),
  6. email.getHostName(),
  7. email.getSmtpPort(),
  8. email.isTLS()));
  9. email.send();
  10. }

代码示例来源:origin: org.apache.commons/commons-email

  1. /**
  2. * Sends the previously created MimeMessage to the SMTP server.
  3. *
  4. * @return the message id of the underlying MimeMessage
  5. * @throws IllegalArgumentException if the MimeMessage has not been created
  6. * @throws EmailException the sending failed
  7. */
  8. public String sendMimeMessage()
  9. throws EmailException
  10. {
  11. EmailUtils.notNull(this.message, "MimeMessage has not been created yet");
  12. try
  13. {
  14. Transport.send(this.message);
  15. return this.message.getMessageID();
  16. }
  17. catch (final Throwable t)
  18. {
  19. final String msg = "Sending the email to the following server failed : "
  20. + this.getHostName()
  21. + ":"
  22. + this.getSmtpPort();
  23. throw new EmailException(msg, t);
  24. }
  25. }

相关文章