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 SMTPTRACEI'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?
Comments
Yes. the SMTPTRACE is the one that will allow log on SMTP (pity that they did not do that by an external parameter)
The DB that you need to mount as RW is IRISLIB
That was the issue. The IRISLIB database was mounted as read-only, so once I gave myself the right permissions and fixed that, I was able to edit it.
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^SmtpTracedo$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
elsedo..SetStatus($$$ERROR($$$SMTPTimeout)) set line=""set responseArray($increment(responseArray))=line
$$$TraceNext(line)
} while$extract(line,4)="-"quit line
}
}I'm probably going to take this approach going forward, but for the moment the amount of rewriting I would have to do to switch everything over to that subclass is a bit more than I want to take on.
To add to @Enrico Parisi's point ... your next upgrade will likely undo your modifications to the %Net.SMTP class.
@David Hockenbroch
I suggest you open a WRC case to request a different way to enable SMTP tracing if the subclass or IRISLIB mounting approaches don't work for your case.
As other have noted, it's the IRISLIB database, not the IRISSYS one, that you need to re-mount writable.