Skip to content

Commit b4f4b9b

Browse files
committed
refactor
1 parent 71778c1 commit b4f4b9b

14 files changed

+56
-57
lines changed

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1-
# hestiacp-maildev
2-
A plugin for Hestia Control Panel (via hesitacp-pluginable) that furnishes multi-tenant MailDev interface for simulated email services development, emulation for sendmail, and SMTP services for each hosted domain.
1+
# hestiacp-mailcatch
2+
A plugin for Hestia Control Panel (via hesitacp-pluginable) that furnishes multitenancy services for simulated SMTP, sendmail, and a unique web GUI for previewing all outgoing emails for each user/web domain.
33

44
 
55
> :warning: !!! Note: this repo is in progress; when completed, a release will appear in the release tab.
66
7+
## Attribution
8+
Based on the slick interface and work from [MailDev](https://github.com/maildev/maildev) and a simulated sendmail compatible command line utility, [catchmail-node](https://github.com/xavierpriour/catchmail-node), these projects have been included and modified with new multitenant capabilities and enhanced compatibility to work "out-of-the-box" under the HestiaCP based control panel.
9+
10+
## Usage
11+
Use MailCatch to test applications that send mail via the local built-in SMTP server and/or sendmail (like PHP's mail() function); this plugin will rename the existing `/usr/sbin/sendmail` to `/usr/sbin/sendmail.sav` and symlink to our sendmail replacement. Unique credentials for the SMTP services can be found in `/home/<username>/web/<domain>/private/smtp.json`. Default SMTP port is 2525 and the username must match the given `<domain>` name. The built-in GUI web client can be found at the URL path `http(s)://<domain>/mailcatch` and as an envelope icon in HestiaCP's web domain listing and edit pages.
12+
13+
714
## Installation
8-
HestiaCP-MailDev requires an Ubuntu based installation of [Hestia Control Panel](https://hestiacp.com) in addition to an installation of [HestiaCP-Pluginable](https://github.com/steveorevo/hestiacp-pluginable) ***and*** [HesitaCP-NodeApp](https://github.com/steveorevo/hestiacp-nodeapp) to function; please ensure that you have first installed both Pluginable and NodeApp on your Hestia Control Panel before proceeding. Switch to a root user and simply clone this project to the /usr/local/hestia/plugins folder. It should appear as a subfolder with the name `maildev`, i.e. `/usr/local/hestia/plugins/maildev`.
15+
HestiaCP-MailCatch requires an Ubuntu based installation of [Hestia Control Panel](https://hestiacp.com) in addition to an installation of [HestiaCP-Pluginable](https://github.com/steveorevo/hestiacp-pluginable) ***and*** [HesitaCP-NodeApp](https://github.com/steveorevo/hestiacp-nodeapp) to function; please ensure that you have first installed both Pluginable and NodeApp on your Hestia Control Panel before proceeding. Switch to a root user and simply clone this project to the /usr/local/hestia/plugins folder. It should appear as a subfolder with the name `mailcatch`, i.e. `/usr/local/hestia/plugins/mailcatch`.
916

1017
First, switch to root user:
1118
```
1219
sudo -s
1320
```
1421

15-
Then simply clone the repo to your plugins folder, with the name `maildev`:
22+
Then simply clone the repo to your plugins folder, with the name `mailcatch`:
1623

1724
```
1825
cd /usr/local/hestia/plugins
19-
git clone https://github.com/steveorevo/hestiacp-maildev maildev
26+
git clone https://github.com/steveorevo/hestiacp-mailcatch mailcatch
2027
```
2128

22-
Note: It is important that the plugin folder name is `maildev`.
29+
Note: It is important that the plugin folder name is `mailcatch`.
2330

24-
Be sure to logout and login again to your Hestia Control Panel as the admin user or, as admin, visit Server (gear icon) -> Configure -> Plugins -> Save; the plugin will immediately start installing MailDev server depedencies in the background. A notification will appear under the admin user account indicating *"MailDev plugin has finished installing"* when complete. This may take awhile before the options appear in Hestia. You can force manual installation via root level SSH:
31+
Be sure to logout and login again to your Hestia Control Panel as the admin user or, as admin, visit Server (gear icon) -> Configure -> Plugins -> Save; the plugin will immediately start installing MailCatch server depedencies in the background. A notification will appear under the admin user account indicating *"MailCatch plugin has finished installing"* when complete. This may take awhile before the options appear in Hestia. You can force manual installation via root level SSH:
2532

2633
```
2734
sudo -s
28-
cd /usr/local/hestia/plugins/maildev
35+
cd /usr/local/hestia/plugins/mailcatch
2936
./install
3037
```

install

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
#!/bin/bash
22
export DEBIAN_FRONTEND=noninteractive
33

4-
adduser maildev --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
4+
adduser mailcatch --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
55
mkdir /opt
66
cd /opt
7-
git clone https://github.com/xavierpriour/catchmail-node ./catchmail-node
8-
chown -R maildev:maildev /opt/catchmail-node
9-
git clone https://github.com/maildev/maildev ./maildev -b v2.0.5
10-
chown -R maildev:maildev /opt/maildev
11-
12-
runuser -l maildev -c "cd /opt/maildev && source /opt/nvm/nvm.sh && nvm use v16 && npm install"
13-
runuser -l maildev -c "cd /opt/catchmail-node && source /opt/nvm/nvm.sh && nvm use v16 && npm install"
14-
15-
cd /usr/local/hestia/plugins/maildev
16-
rsync -r ./nodeapp/ /opt/maildev/
17-
chown -R maildev:maildev /opt/maildev
18-
19-
/usr/local/hestia/bin/v-add-user-notification admin "MailDev" "<span style=\"color:#4994CE;\"><i class=\"fas fa-envelope\"></i></span> MailDev has finished installing."
7+
git clone https://github.com/maildev/maildev ./mailcatch -b v2.0.5
8+
cd /usr/local/hestia/plugins/mailcatch
9+
rsync -r ./src/ /opt/mailcatch
10+
chown -R mailcatch:mailcatch /opt/mailcatch
11+
runuser -l mailcatch -c "cd /opt/mailcatch && source /opt/nvm/nvm.sh && nvm use v16 && npm install"
12+
/usr/local/hestia/bin/v-add-user-notification admin "MailCatch" "<span style=\"color:#4994CE;\"><i class=\"fas fa-envelope\"></i></span> MailCatch has finished installing."

maildev.php renamed to mailcatch.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<?php
22
/**
3-
* Extend the HestiaCP Pluginable object with our MailDev object for
4-
* our system-wide MailDev service.
3+
* Extend the HestiaCP Pluginable object with our MailCatch object for
4+
* our system-wide MailCatch service.
55
*
66
* @version 1.0.0
77
* @license GPL-3.0
8-
* @link https://github.com/steveorevo/hestiacp-maildev
8+
* @link https://github.com/steveorevo/hestiacp-mailcatch
99
*
1010
*/
1111

12-
if ( ! class_exists( 'MailDev') ) {
13-
class MailDev {
12+
if ( ! class_exists( 'MailCatch') ) {
13+
class MailCatch {
1414
/**
1515
* Constructor, listen for the render events
1616
*/
1717
public function __construct() {
1818
global $hcpp;
19-
$hcpp->maildev = $this;
19+
$hcpp->mailcatch = $this;
2020
$hcpp->add_action( 'render_page', [ $this, 'render_page' ] );
2121
$hcpp->add_action( 'priv_unsuspend_domain', [ $this, 'priv_unsuspend_domain' ] );
2222
$hcpp->add_action( 'hcpp_plugin_installed', [ $this, 'hcpp_plugin_installed' ] );
@@ -31,19 +31,19 @@ public function create_smtp_json( $user, $domain ) {
3131
$password = $hcpp->nodeapp->random_chars( 16 );
3232
$content = "{\n \"username\": \"$domain\",\n \"password\": \"$password\",\n \"port\": 2525\n}";
3333
file_put_contents( $file, $content );
34-
shell_exec( "chown $user:maildev $file && chmod 640 $file" );
34+
shell_exec( "chown $user:mailcatch $file && chmod 640 $file" );
3535
}
3636

37-
// Setup the MailDev Server instance for the domain
37+
// Setup the MailCatch Server instance for the domain
3838
public function setup( $user, $domain ) {
3939
global $hcpp;
40-
$conf = "/home/$user/conf/web/$domain/nginx.conf_maildev";
41-
$content = file_get_contents( __DIR__ . '/conf-web/nginx.conf_maildev' );
40+
$conf = "/home/$user/conf/web/$domain/nginx.conf_mailcatch";
41+
$content = file_get_contents( __DIR__ . '/conf-web/nginx.conf_mailcatch' );
4242
file_put_contents( $conf, $content );
4343

44-
// Create the nginx.conf_maildev file.
45-
$conf = "/home/$user/conf/web/$domain/nginx.ssl.conf_maildev";
46-
$content = file_get_contents( __DIR__ . '/conf-web/nginx.ssl.conf_maildev' );
44+
// Create the nginx.conf_mailcatch file.
45+
$conf = "/home/$user/conf/web/$domain/nginx.ssl.conf_mailcatch";
46+
$content = file_get_contents( __DIR__ . '/conf-web/nginx.ssl.conf_mailcatch' );
4747
file_put_contents( $conf, $content );
4848

4949
// Ensure system.ports is included
@@ -76,7 +76,7 @@ public function new_web_domain_ready( $args ) {
7676
return $args;
7777
}
7878

79-
// Add MailDev icon next to our web domain list and domain edit pages.
79+
// Add MailCatch icon next to our web domain list and domain edit pages.
8080
public function render_page( $args ) {
8181
if ( $args['page'] == 'list_web' ) {
8282
$args = $this->render_list_web( $args );
@@ -87,16 +87,16 @@ public function render_page( $args ) {
8787
return $args;
8888
}
8989

90-
// Add MailDev icon to our web domain edit page.
90+
// Add MailCatch icon to our web domain edit page.
9191
public function render_edit_web( $args ) {
9292
global $hcpp;
9393
$domain = $_GET['domain'];
9494
$content = $args['content'];
9595

9696
// Create white envelope icon button to appear before Quick Installer button
97-
$code = '<a href="https://' . $domain . '/maildev" target="_blank" class="ui-button cancel" ';
97+
$code = '<a href="https://' . $domain . '/mailcatch" target="_blank" class="ui-button cancel" ';
9898
$code .= 'dir="ltr"><i class="fas fa-envelope status-icon highlight">';
99-
$code .= '</i> MailDev</a>';
99+
$code .= '</i> MailCatch</a>';
100100

101101
// Inject the button into the page's toolbar buttonstrip
102102
$quick = '"fas fa-magic status-icon blue';
@@ -109,15 +109,15 @@ public function render_edit_web( $args ) {
109109
return $args;
110110
}
111111

112-
// Add MailDev icon to our web domain list page.
112+
// Add MailCatch icon to our web domain list page.
113113
public function render_list_web( $args ) {
114114
global $hcpp;
115115
$content = $args['content'];
116116

117117
// Create white envelope icon before pencil/edit icon
118118
$div = '<div class="actions-panel__col actions-panel__edit shortcut-enter" key-action="href">';
119119
$code = '<div class="actions-panel__col actions-panel__code" key-action="href">
120-
<a href="https://%domain%/maildev" rel="noopener" target="_blank" title="Open MailDev">
120+
<a href="https://%domain%/mailcatch" rel="noopener" target="_blank" title="Open MailCatch">
121121
<i class="fas fa-envelope status-icon highlight status-icon dim"></i>
122122
</a></div>&nbsp;';
123123
$new = '';
@@ -138,17 +138,17 @@ public function render_list_web( $args ) {
138138

139139
// Allocate port on and start server on install
140140
public function hcpp_plugin_installed( $plugin_name ) {
141-
if ( $plugin_name != 'maildev' ) return $plugin_name;
141+
if ( $plugin_name != 'mailcatch' ) return $plugin_name;
142142
global $hcpp;
143-
$port = $hcpp->allocate_port( 'maildev_port' );
143+
$port = $hcpp->allocate_port( 'mailcatch_port' );
144144

145-
// Start the single system-wide MailDev Server instance
146-
$cmd = "runuser -l maildev -c \"cd /opt/maildev && source /opt/nvm/nvm.sh ; pm2 start maildev.config.js\"";
145+
// Start the single system-wide MailCatch Server instance
146+
$cmd = "runuser -l mailcatch -c \"cd /opt/mailcatch && source /opt/nvm/nvm.sh ; pm2 start mailcatch.config.js\"";
147147
$hcpp->log( shell_exec( $cmd ) );
148148
return $plugin_name;
149149
}
150150

151-
// TODO: when domain is deleted, cleanup the domain in maildev; i.e. rm -rf /tmp/maildev/$domain_*
151+
// TODO: when domain is deleted, cleanup the domain in mailcatch; i.e. rm -rf /tmp/mailcatch/$domain_*
152152
}
153-
new MailDev();
153+
new MailCatch();
154154
}

plugin.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
3-
* Plugin Name: MailDev
4-
* Plugin URI: https://github.com/steveorevo/hestiacp-maildev
5-
* Description: MailDev furnishes a multi-tenant interface for simulated email services, sendmail emulation, and SMTP services for each hosted domain.
3+
* Plugin Name: MailCatch
4+
* Plugin URI: https://github.com/steveorevo/hestiacp-mailcatch
5+
* Description: MailCatch furnishes a multi-tenant interface for simulated email services, sendmail emulation, and SMTP services for each hosted domain.
66
*/
77

88
// Register the install and uninstall scripts
99
global $hcpp;
10-
require_once( dirname(__FILE__) . '/maildev.php' );
10+
require_once( dirname(__FILE__) . '/mailcatch.php' );
1111

1212
$hcpp->register_install_script( dirname(__FILE__) . '/install' );
1313
$hcpp->register_uninstall_script( dirname(__FILE__) . '/uninstall' );
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

uninstall

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash
2-
runuser -l maildev -c "cd /opt/maildev && source /opt/nvm/nvm.sh && pm2 delete maildev ; pm2 save --force"
3-
rm -rf /opt/maildev
4-
rm -rf /opt/catchmail-node
5-
deluser maildev
6-
rm -rf /home/maildev
7-
php -r "include('/usr/local/hestia/web/pluginable.php');global \$hcpp;\$hcpp->delete_port('maildev_port');"
2+
runuser -l mailcatch -c "cd /opt/mailcatch && source /opt/nvm/nvm.sh && pm2 delete mailcatch ; pm2 save --force"
3+
rm -rf /opt/mailcatch
4+
deluser mailcatch
5+
rm -rf /home/mailcatch
6+
php -r "include('/usr/local/hestia/web/pluginable.php');global \$hcpp;\$hcpp->delete_port('mailcatch_port');"

0 commit comments

Comments
 (0)