Using Email Security Drivers

The following steps demonstrate how you can use the UPOPMAIL component operations to call an email security driver from ProcScript using the SMTP Auth Login driver.

The steps are the same for the other security drivers. For SMTP, you can one of SMTP security drivers. For authentication on POP servers, you can use the XOAUTH2 driver.

If you use the SMTP STARTTLS server, you need to use both it and an authenticating security driver. For more information, see SMTP STARTTLS Security Driver.

To use an email security driver in your application:

  1. Configure the Uniface application so that it can locate the security driver. In the [USER_3GL ] section of the application assignment file, declare the entry point of the driver.

    For example:

    [USER_3GL]
    InstallDir\common\bin\uauthlogin(UAuthLoginSMTP)
  2. Set the security context by activating the SetSecurity operation of the UPOPMAIL component. For example:
    variables
      handle hMail
      string vSetProps, vSetParams, vGetProps, vRetInfo, vItemValue					
    endvariables
    
    ; Create an instance of UPOPMAIL
    newinstance	UPOPMAIL, hMail
    				
    ;Place a security driver into the security context:
    vSetProps = "SMTP=UAuthLoginSMTP;USE=opt"
    vSetParams = "USER=smtp_username;PASSWORD=smtp_password"
    
    hMail->SetSecurity(vSetProps, vSetParams)
    if ($status < 0)
          done
    endif
    
  3. Verify that the driver has been correctly added to the security context.
    ; Check that there is a driver in the security context
    vGetProps = "SMTP="
    hMail->GetSecurity(1, vGetProps, vRetInfo)
    if ($status != 0)
       done
    endif
    					
    ; The returned properties should be the same
    if (vGetProps != vSetProps)
       done
    endif
    					
    ; Check the runtime information
    getitem/id vItemValue, vRetInfo, "INUSE"
    if (vItemValue != "FALSE")
       done
    endif
  4. Logon to the SMTP server using the LogonSMTP operation.
    ; Log on using the security context
    
    hMail->LogonSMTP("smtp.myorg.com", "", "")
    if ($status != 0)
       done
    endif
  5. Once the connection is established, you can continue to obtain information about the security context.
    ; Check that there is a driver in the security context
    vGetProps = "SMTP="
    
    hMail->GetSecurity(1, vGetProps, vRetInfo)
    if ($status != 0)
       done
    endif
    					
    ; Check the runtime information
    getitem/id vItemValue, vRetInfo, "INUSE"
    if (vItemValue != "TRUE")
       done
    endif

Related Topics