Question
· Jan 8

Can't edit %Net.SMTP despite having %DB_IRISSYS and database mounted as RW?

I need to see the full SMTP trace when a %Net.SMTP attempts to send an email to troubleshoot an issue. As far as I know, the only way to get that is to uncomment line 192 in the %Net.SMTP class.

 //:#define SMTPTRACE

I've done this in the past by giving myself the %DB_IRISSYS role, so I tried that. That database is also not mounted as read-only.

Of course the bigger issue here is that I can't seem to get that trace without having to edit a system class or create my own, but to fix my more immediate issue, what else do I need to check that would be preventing me from editing that class?

Product version: IRIS 2021.1
$ZV: IRIS for UNIX (Red Hat Enterprise Linux for x86-64) 2021.1 (Build 215U) Wed Jun 9 2021 09:48:12 EDT
Discussion (7)5
Log in or sign up to continue

IMO a better option would be to create a subclass of %Net.SMTP and copy and modify the GetResponse() method code uncommenting that line.

Then use this class instead of %Net.SMTP.

This way you don't need "to mess" system classes, change system  database configuration (RW in IRISLIB) and then you have full control of the code.

Something like:

Class My.Net.SMTP Extends %Net.SMTP
{

/// Get response to mail command.  Use timeout as specified by RFC1123. 
Method GetResponse(timeout As %Integer, ByRef responseArray As %String) As %String [ Internal, Private ]
{
#define SMTPTRACE
#ifdef SMTPTRACE
#define TraceInit  try { kill ^SmtpTrace } catch { set killsave=$zu(68,28,0) kill ^SmtpTrace do $zu(68,28,killsave) }
#define TraceNext(%line) set ^SmtpTrace($increment(^SmtpTrace))=%line_"<<"_$zb
#else
#define TraceInit
#define TraceNext(%line)
#endif

#define WriteText(%text) $$$TraceNext(">>"_%text) write %text
#define WriteLine(%text) $$$WriteText(%text),!
 kill responseArray
 set line=""
 do {
 	read line:timeout
 	else  do ..SetStatus($$$ERROR($$$SMTPTimeout)) set line=""
 	set responseArray($increment(responseArray))=line
 	$$$TraceNext(line)
 } while $extract(line,4)="-"
 quit line
}

}