Debugging errors with FILENAME Statement: EMAIL (SMTP) Access Methods and SMTP servers


This article covers how to debug errors with FILENAME Statement: EMAIL (SMTP) Access Methods and SMTP servers.

Table of Contents

Verifying SAS EMAIL Options

SAS EMAIL options specify the details for the SMTP server. For information, see SAS Help Center: System Options That Control SMTP E-Mail.

To check these options and where they are set, run the following SAS code:

PROC OPTIONS GROUP=EMAIL VALUE; RUN;
 

Debugging FILENAME EMAIL Access Method Errors

Many errors generated by the FILENAME EMAIL Access Method code are messages from the SMTP server. You can find details about many of these SMTP errors and their resolution by searching from a web browser.

To see the standard SMTP communication between SAS (SMTP client) and the SMTP server, add the DEBUG parameter to the FILENAME EMAIL statement:

FILENAME MYEMAIL EMAIL ..... DEBUG;

DEBUG information is written to the SAS log:

Here's an example:


R: 250-STARTTLS
R: 250-AUTH LOGIN

If no additional information is provided by the DEBUG parameter, the SAS connection is not communicating with the SMTP server that is specified by SAS EMAIL options. You should review the values set for the SAS EMAILHOST= and EMAILPORT= options.

Note: On Microsoft Windows, if you are using the SAS option EMAILSYS=MAPI, then you do not receive DEBUG information.   

 

Handling SSL or OpenSSL Errors for Secure SMTP Server Connections    

If you encounter SSL or OpenSSL errors with your SMTP server connection, you need to obtain the SAS TLS enhanced logging. This logging shows you the behind-the-scenes TLS negotiations/details for the secure SMTP server connection. To obtain the enhanced logging, add the following before your FILENAME EMAIL code from a Foundation SAS® session (batch, DMS, or linemode):



%log4sas(); 
%log4sas_logger('App.tk.eam.ssl', 'level=trace');   
run; 
<your existing FILENAME EMAIL SAS code>;

 

Note: The %log4sas macros do not work successfully from a Workspace Server or other SAS servers using the -LOGCONFIGLOC option.
 

If the FILENAME EMAIL SSL error cannot be replicated from a Foundation SAS session, obtain SSL/TLS details using the -LOGCONFIGLOC option and the logconfig.trace.xml file.


Before making any changes, you should work with SAS Technical Support since this step creates additional information written to logs for all users.