67 $this->enable = $this->enable &&
$bearsamppConfig->getRaw( self::ROOT_CFG_ENABLE );
71 if ( $this->bearsamppConfRaw !==
false ) {
72 $this->exe = $this->symlinkPath .
'/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
73 $this->webRoot = $this->bearsamppConfRaw[self::LOCAL_CFG_WEB_ROOT];
74 $this->uiPort = intval( $this->bearsamppConfRaw[self::LOCAL_CFG_UI_PORT] );
75 $this->smtpPort = intval( $this->bearsamppConfRaw[self::LOCAL_CFG_SMTP_PORT] );
76 $this->listen = $this->bearsamppConfRaw[self::LOCAL_CFG_LISTEN];
79 if ( !$this->enable ) {
84 if ( !is_dir( $this->currentPath ) ) {
89 if ( !is_dir( $this->symlinkPath ) ) {
94 if ( !is_file( $this->bearsamppConf ) ) {
99 if ( !is_file( $this->exe ) ) {
104 if ( (empty( $this->webRoot ) && $this->webRoot !==
'' || is_numeric( $this->webRoot )) ) {
109 if ( empty( $this->uiPort ) ) {
114 if ( empty( $this->smtpPort ) ) {
119 if ( empty( $this->listen ) ) {
125 $nssm =
new Nssm( self::SERVICE_NAME );
127 $nssm->setBinPath( $this->exe );
128 $nssm->setParams( sprintf( self::SERVICE_PARAMS, $this->listen, $this->uiPort, $this->listen, $this->smtpPort, $this->webRoot ) );
130 $nssm->setStdout(
$bearsamppRoot->getLogsPath() .
'/mailpit.out.log' );
131 $nssm->setStderr(
$bearsamppRoot->getLogsPath() .
'/mailpit.err.log' );
133 $this->service->setNssm( $nssm );
143 $content = file_get_contents( $this->bearsamppConf );
145 foreach ( $params as $key => $value ) {
146 $content = preg_replace(
'|' . $key .
' = .*|', $key .
' = ' .
'"' . $value .
'"', $content );
147 $this->bearsamppConfRaw[$key] = $value;
149 case self::LOCAL_CFG_UI_PORT:
150 $this->uiPort = intval( $value );
152 case self::LOCAL_CFG_SMTP_PORT:
153 $this->smtpPort = intval( $value );
158 file_put_contents( $this->bearsamppConf, $content );
168 global $bearsamppRegistry;
171 Util::logTrace(
"Checking if registry key exists for Mailpit service parameters");
173 $registryPath =
'SYSTEM\CurrentControlSet\Services\\' . self::SERVICE_NAME .
'\Parameters';
176 $exists = $bearsamppRegistry->exists(
183 Util::logTrace(
"Registry key exists, updating service parameters");
185 $serviceParams = sprintf(self::SERVICE_PARAMS, $this->listen, $this->uiPort, $this->listen, $this->smtpPort, $this->webRoot);
188 $result = $bearsamppRegistry->setExpandStringValue(
199 Util::logTrace(
"Registry key does not exist for Mailpit service parameters");
324 if ( !$this->enable ) {
329 Util::logDebug( ($sub > 0 ? str_repeat(
' ', 2 * $sub ) :
'') .
'Update ' . $this->name .
' ' .
$version .
' config' );
337 $bearsamppWinbinder->messageBoxError(
350 $bearsamppWinbinder->messageBoxError(
394 public function setEnable($enabled, $showWindow =
false)
401 $bearsamppWinbinder->messageBoxError(
414 if ( $this->enable ) {