code: public static void configureMail(CmsMailHost host, Email mail) {
  
          // set the host to the default mail host
          mail.setHostName(host.getHostname());
          mail.setSmtpPort(host.getPort());
  
          // check if username and password are provided
          String userName = host.getUsername();
          if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(userName)) {
              // authentication needed, set user name and password
              mail.setAuthentication(userName, host.getPassword());
          }
          String security = host.getSecurity() != null ? host.getSecurity().trim() : null;
          if (SECURITY_SSL.equalsIgnoreCase(security)) {
              mail.setSslSmtpPort("" + host.getPort());
              mail.setSSLOnConnect(true);
          } else if (SECURITY_STARTTLS.equalsIgnoreCase(security)) {
              mail.setStartTLSEnabled(true);
          }
  
          try {
              // set default mail from address
              mail.setFrom(OpenCms.getSystemInfo().getMailSettings().getMailFromDefault());
          } catch (EmailException e) {
              // default email address is not valid, log error
              LOG.error(Messages.get().getBundle().key(Messages.LOG_INVALID_SENDER_ADDRESS_0), e);
          }
      }
docs: Configures the mail from the given mail host configuration data.<p>
  
  @param host the mail host configuration
  @param mail the email instance