You have the following options to execute the cleanup of the IBM i SMTP MCB objects.
The cleanup process can be safely ended at any time using the CL command, ENDJOB JOB(jobnum/jobuser/CLEANMAIL) OPTION(*IMMED), if you choose not to run the cleanup to completion. The program incrementally cleans up the MCB objects. When ended in the middle of its processing, it will stop the cleanup and then when the cleanup is submitted next, it will pick up where it left off. Running the cleanup process for a shorter period of time may allow the IBM i SMTP and MSF servers to start and resolve your immediate issue. However, IBM recommends you run the cleanup process to completion at some point when a maintenance window can be scheduled.
Option 2: End the IBM i SMTP and MSF servers and keep them ended while the cleanup process executes.
This will prevent the loss of any emails due to the cleanup process. Since the *SDD email directory type leverages MCB objects to process emails, starting the SMTP and MSF servers while the cleanup process is running may result in the loss of emails.
CALL QTCP/QTMSWRKMCB 'LIST'
ENDMSF
ENDTCPSVR *SMTP
SBMJOB CMD(CALL PGM(QTCP/QTMSWRKMCB) PARM('CLEAN')) JOB(CLEANMAIL) JOBQ(QSYSNOMAX) LOG(4 30 *SECLVL)
The cleanup progress can be observed in the submitted job log (i.e. DSPJOBLOG JOB(CLEANMAIL)) or by executing the CL command, CALL QTCP/QTMSWRKMCB 'LIST'.
Once the CLEANMAIL job ends or is ended, you can restart the MSF and SMTP Servers.
STRTCPSVR *SMTP
STRMSF
Option 3: Execute the cleanup at the next start of the IBM i SMTP Server.
This will delay the startup of the IBM i SMTP Server and Client until the cleanup process has completed.
CALL QTCP/QTMSWRKMCB 'LIST'
ENDMSF
ENDTCPSVR *SMTP
CHGSMTPA COLDSTART(*YES)
ADDENVVAR ENVVAR(QIBM_SMTP_COLLECT_MCB_LSTOBJ) LEVEL(*SYS)
STRTCPSVR *SMTP
Wait for the IBM i SMTP Server to fully start.
STRMSF
The cleanup progress can be observed in the QTSMTPSRVD job log (i.e. DSPJOBLOG JOB(QTSMTPSRVD)) or by executing the CL command, CALL QTCP/QTMSWRKMCB 'LIST'.
The IBM i SMTP Server will fully start once the cleanup process has completed.
Option 4: Run the cleanup process while the IBM i SMTP and MSF Servers are active.
WARNING!!! This may result in the loss of emails when the IBM i SMTP Email Directory Type is set to the *SDD value. This is because the *SDD email directory type architecture leverages internal MCB objects to process emails. When the cleanup process is running, the internal MCB objects related to your normal emails may be deleted causing email delivery failures. If you want to avoid this issue, IBM recommends you end the IBM i SMTP and MSF servers and keep them ended while the cleanup process executes. The servers can be restarted after the cleanup process is ended or runs to completion.
CALL QTCP/QTMSWRKMCB 'LIST'
SBMJOB CMD(CALL PGM(QTCP/QTMSWRKMCB) PARM('CLEAN')) JOB(CLEANMAIL) JOBQ(QSYSNOMAX) LOG(4 30 *SECLVL)
The cleanup progress can be observed in the submitted job log (i.e. DSPJOBLOG JOB(CLEANMAIL)) or by executing the CL command, CALL QTCP/QTMSWRKMCB 'LIST'.