emailengine-app 2.84.0 → 2.84.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/.dockerignore +6 -0
  2. package/.release-please-manifest.json +1 -1
  3. package/CHANGELOG.md +35 -0
  4. package/Dockerfile +2 -2
  5. package/bin/emailengine.js +15 -0
  6. package/data/google-crawlers.json +1 -1
  7. package/docker-compose.yml +1 -1
  8. package/lib/account/own-account-key.js +42 -0
  9. package/lib/account-assignment.js +1 -33
  10. package/lib/account.js +32 -19
  11. package/lib/add-trackers.js +11 -4
  12. package/lib/api-routes/account-routes.js +67 -14
  13. package/lib/api-routes/gateway-routes.js +9 -3
  14. package/lib/api-routes/message-routes.js +7 -1
  15. package/lib/api-routes/mint-bounds.js +11 -0
  16. package/lib/api-routes/route-helpers.js +125 -3
  17. package/lib/api-routes/submit-routes.js +4 -2
  18. package/lib/auth-token.js +23 -10
  19. package/lib/bounce-detect.js +17 -5
  20. package/lib/consts.js +34 -0
  21. package/lib/create-imap-client.js +41 -2
  22. package/lib/email-client/base-client.js +20 -10
  23. package/lib/email-client/gmail-client.js +21 -7
  24. package/lib/email-client/imap/mailbox.js +10 -4
  25. package/lib/email-client/imap/response-metrics.js +75 -0
  26. package/lib/email-client/imap-client.js +5 -2
  27. package/lib/email-client/message-builder.js +7 -2
  28. package/lib/email-client/outlook/graph-api.js +17 -2
  29. package/lib/email-client/outlook-client.js +6 -3
  30. package/lib/email-client/smtp-pool-manager.js +6 -0
  31. package/lib/encrypt.js +9 -0
  32. package/lib/export.js +3 -1
  33. package/lib/get-raw-email.js +4 -2
  34. package/lib/imap-proxy-auth.js +14 -1
  35. package/lib/imapproxy/imap-core/lib/commands/authenticate-plain.js +1 -0
  36. package/lib/imapproxy/imap-core/lib/commands/login.js +1 -0
  37. package/lib/imapproxy/imap-core/lib/imap-command.js +86 -43
  38. package/lib/imapproxy/imap-core/lib/imap-stream.js +58 -13
  39. package/lib/imapproxy/imap-core/lib/indexer/indexer.js +3 -1
  40. package/lib/mcp/listen.js +10 -1
  41. package/lib/oauth/external-account-config.js +3 -1
  42. package/lib/oauth/gmail.js +21 -48
  43. package/lib/oauth/mail-ru.js +5 -38
  44. package/lib/oauth/outlook.js +26 -44
  45. package/lib/pbkdf2-phc.js +18 -1
  46. package/lib/privileged-settings.js +6 -3
  47. package/lib/redis-scan-delete.js +15 -1
  48. package/lib/schemas.js +78 -32
  49. package/lib/settings.js +13 -1
  50. package/lib/smtp-auth.js +23 -0
  51. package/lib/tools.js +245 -56
  52. package/lib/ui-routes/account-routes.js +16 -37
  53. package/lib/ui-routes/admin-config-routes.js +10 -38
  54. package/lib/ui-routes/admin-entities-routes.js +22 -24
  55. package/lib/ui-routes/auth-routes.js +47 -24
  56. package/lib/ui-routes/connection-security-form.js +74 -0
  57. package/lib/ui-routes/form-lists.js +46 -0
  58. package/lib/ui-routes/mcp-consent-routes.js +5 -1
  59. package/lib/ui-routes/oauth-config-routes.js +9 -18
  60. package/lib/ui-routes/sign-in-helpers.js +59 -0
  61. package/lib/ui-routes/unsubscribe-routes.js +6 -3
  62. package/lib/utils/map-concurrent.js +36 -0
  63. package/lib/utils/network.js +28 -0
  64. package/lib/utils/provider-id.js +27 -0
  65. package/lib/utils/require-tls.js +33 -0
  66. package/lib/web-safe-html.js +5 -6
  67. package/lib/webhook-penalty.js +75 -0
  68. package/lib/webhook-routing.js +22 -2
  69. package/package.json +21 -21
  70. package/sbom.json +1 -1
  71. package/server.js +74 -38
  72. package/static/js/ace/ace.js +1 -1
  73. package/static/js/ace/mode-handlebars.js +1 -1
  74. package/static/js/ace/mode-html.js +1 -1
  75. package/static/js/ace/mode-javascript.js +1 -1
  76. package/static/js/ace/mode-markdown.js +1 -1
  77. package/static/js/ace/worker-html.js +1 -1
  78. package/static/js/ace/worker-javascript.js +1 -1
  79. package/static/js/ace/worker-json.js +1 -1
  80. package/static/js/ee-client.js +5 -0
  81. package/static/licenses.html +23 -23
  82. package/translations/messages.pot +66 -66
  83. package/views/account/security.hbs +10 -0
  84. package/views/accounts/account.hbs +11 -11
  85. package/views/accounts/edit.hbs +6 -2
  86. package/views/partials/gateway_form.hbs +3 -1
  87. package/workers/api.js +43 -3
  88. package/workers/webhooks.js +39 -3
  89. package/config/test.toml +0 -46
  90. package/install.sh +0 -428
  91. package/setup-production.sh +0 -215
  92. package/systemd/emailengine.service +0 -97
  93. package/systemd/nginx-proxy.conf +0 -77
@@ -1,215 +0,0 @@
1
- #!/bin/bash
2
-
3
- # EmailEngine Production Setup Script
4
- # This script helps initialize a production-ready EmailEngine deployment
5
-
6
- set -e
7
-
8
- # Colors for output
9
- RED='\033[0;31m'
10
- GREEN='\033[0;32m'
11
- YELLOW='\033[1;33m'
12
- NC='\033[0m' # No Color
13
-
14
- # Function to print colored output
15
- print_message() {
16
- local color=$1
17
- local message=$2
18
- echo -e "${color}${message}${NC}"
19
- }
20
-
21
- # Function to generate secure random strings
22
- generate_secret() {
23
- openssl rand -hex 32 2>/dev/null || cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1
24
- }
25
-
26
- generate_password() {
27
- openssl rand -base64 32 2>/dev/null || cat /dev/urandom | tr -dc 'a-zA-Z0-9!@#$%^&*()_+' | fold -w 32 | head -n 1
28
- }
29
-
30
- print_message $GREEN "==================================="
31
- print_message $GREEN "EmailEngine Production Setup"
32
- print_message $GREEN "==================================="
33
- echo
34
-
35
- # Check prerequisites
36
- print_message $YELLOW "Checking prerequisites..."
37
-
38
- if ! command -v docker &> /dev/null; then
39
- print_message $RED "Error: Docker is not installed"
40
- exit 1
41
- fi
42
-
43
- # Docker Compose ships either as the `docker compose` plugin - every current Docker Desktop and
44
- # Docker Engine install - or as the standalone `docker-compose` binary. Resolved into one variable
45
- # here and used everywhere below: the check accepted either form while the start step ran the binary,
46
- # so a host carrying only the plugin passed this script's own prerequisite check and then failed to
47
- # start anything.
48
- if docker compose version &> /dev/null; then
49
- COMPOSE="docker compose"
50
- elif command -v docker-compose &> /dev/null; then
51
- COMPOSE="docker-compose"
52
- else
53
- print_message $RED "Error: Docker Compose is not installed"
54
- exit 1
55
- fi
56
-
57
- print_message $GREEN "✓ Prerequisites checked"
58
- echo
59
-
60
- # Check if docker-compose file exists
61
- if [ ! -f "docker-compose.yml" ]; then
62
- print_message $RED "Error: docker-compose.yml not found"
63
- print_message $YELLOW "Please ensure you're running this script from the EmailEngine directory"
64
- exit 1
65
- fi
66
-
67
- # Everything this script writes from here on (the .env file and its backup) holds EENGINE_SECRET and
68
- # generated passwords, so create them owner-only from birth instead of tightening after the fact.
69
- umask 077
70
-
71
- # Create .env file if it doesn't exist
72
- if [ -f ".env" ]; then
73
- print_message $YELLOW "Warning: .env file already exists"
74
- read -p "Do you want to overwrite it? (y/N): " -n 1 -r
75
- echo
76
- if [[ ! $REPLY =~ ^[Yy]$ ]]; then
77
- print_message $YELLOW "Setup cancelled. Existing .env file preserved."
78
- exit 0
79
- fi
80
- # Backup existing .env. It holds EENGINE_SECRET and generated passwords; umask 077 (set above)
81
- # keeps the copy owner-only from creation rather than leaving a world-readable window.
82
- cp .env ".env.backup.$(date +%Y%m%d-%H%M%S)"
83
- print_message $GREEN "✓ Existing .env backed up"
84
- fi
85
-
86
- print_message $YELLOW "Generating secure credentials..."
87
-
88
- # Generate secure values
89
- EENGINE_SECRET=$(generate_secret)
90
- REDIS_PASSWORD=$(generate_password)
91
- SMTP_PASSWORD=$(generate_password)
92
-
93
- # Create .env file
94
- cat > .env << EOF
95
- # EmailEngine Production Environment Configuration
96
- # Generated on $(date)
97
-
98
- # ===========================================
99
- # REQUIRED SECURITY SETTINGS
100
- # ===========================================
101
-
102
- # Encryption secret for EmailEngine
103
- EENGINE_SECRET=${EENGINE_SECRET}
104
-
105
- # Redis password
106
- REDIS_PASSWORD=${REDIS_PASSWORD}
107
-
108
- # Redis connection with authentication
109
- EENGINE_REDIS=redis://:${REDIS_PASSWORD}@redis:6379/2
110
-
111
- # ===========================================
112
- # EMAILENGINE CONFIGURATION
113
- # ===========================================
114
-
115
- # Log level (error, warn, info, debug)
116
- EENGINE_LOG_LEVEL=info
117
-
118
- # Number of worker processes (adjust based on your CPU cores, min 4, max 24)
119
- EENGINE_WORKERS=8
120
-
121
- # EmailEngine settings (JSON format)
122
- EENGINE_SETTINGS={"smtpServerEnabled": true, "smtpServerPort": 2525, "smtpServerHost": "0.0.0.0", "smtpServerAuthEnabled": true, "smtpServerPassword": "${SMTP_PASSWORD}"}
123
-
124
- # ===========================================
125
- # REDIS CONFIGURATION
126
- # ===========================================
127
-
128
- # Redis is used as a database - no memory limit, no eviction
129
- # Monitor usage with: ${COMPOSE} exec redis redis-cli INFO memory
130
- REDIS_LOG_LEVEL=notice
131
-
132
- # ===========================================
133
- # DATA PERSISTENCE
134
- # ===========================================
135
-
136
- # ===========================================
137
- # SERVICE EXPOSURE (PRODUCTION)
138
- # ===========================================
139
-
140
- # Bind only to localhost for production
141
- EMAILENGINE_API_BIND=127.0.0.1
142
- EMAILENGINE_SMTP_BIND=127.0.0.1
143
- EMAILENGINE_IMAP_BIND=127.0.0.1
144
-
145
- # ===========================================
146
- # HEALTH CHECKS
147
- # ===========================================
148
-
149
- # Use strict health checks for production
150
- REDIS_HEALTHCHECK=service_healthy
151
- HEALTHCHECK_INTERVAL=30s
152
-
153
- # ===========================================
154
- # OTHER SETTINGS
155
- # ===========================================
156
-
157
- RESTART_POLICY=unless-stopped
158
- LOG_COMPRESS=true
159
- EOF
160
-
161
- print_message $GREEN "✓ .env file created with secure credentials"
162
- echo
163
-
164
- # Note about Redis data
165
- print_message $YELLOW "Note: Redis data will be stored in a Docker volume"
166
-
167
- print_message $GREEN "✓ Using unified docker-compose.yml with production settings"
168
- echo
169
-
170
- # Display credentials
171
- print_message $GREEN "==================================="
172
- print_message $GREEN "Setup Complete!"
173
- print_message $GREEN "==================================="
174
- echo
175
- print_message $YELLOW "Important: Save these credentials securely!"
176
- echo
177
- echo "SMTP Password: ${SMTP_PASSWORD}"
178
- echo
179
- print_message $YELLOW "The encryption secret and Redis password have been"
180
- print_message $YELLOW "securely stored in the .env file."
181
- echo
182
-
183
- # Offer to start services
184
- read -p "Would you like to start EmailEngine now? (y/N): " -n 1 -r
185
- echo
186
- if [[ $REPLY =~ ^[Yy]$ ]]; then
187
- print_message $YELLOW "Starting EmailEngine services..."
188
- $COMPOSE pull
189
- $COMPOSE up -d
190
-
191
- # Wait for services to start
192
- sleep 5
193
-
194
- # Check status
195
- if $COMPOSE ps | grep -q "Up"; then
196
- print_message $GREEN "✓ EmailEngine is running!"
197
- echo
198
- print_message $GREEN "Access the web interface at: http://localhost:3000"
199
- print_message $GREEN "SMTP server available at: localhost:2525"
200
- print_message $GREEN "IMAP proxy available at: localhost:9993"
201
- echo
202
- print_message $YELLOW "Default admin credentials:"
203
- echo "Username: admin"
204
- echo "Password: (not set - you'll be prompted to create one on first login)"
205
- else
206
- print_message $RED "Warning: Some services may not have started correctly"
207
- print_message $YELLOW "Check logs with: $COMPOSE logs"
208
- fi
209
- else
210
- print_message $YELLOW "To start EmailEngine later, run:"
211
- echo "$COMPOSE up -d"
212
- fi
213
-
214
- echo
215
- print_message $GREEN "For detailed deployment instructions, see DOCKER_DEPLOYMENT.md"
@@ -1,97 +0,0 @@
1
- # Example systemd unit file for EmailEngine
2
-
3
- # Requires Node.js and Redis
4
- # Installation instructions for Node.js:
5
- # https://nodejs.org/en/download/package-manager/
6
- # Install Redis on Ubuntu:
7
- # https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04
8
-
9
- # Copy this file to /etc/systemd/system/emailengine.service
10
-
11
- # Once set up (or service file is modified) run as root:
12
- # systemctl daemon-reload
13
- # systemctl enable emailengine
14
- # systemctl restart emailengine
15
-
16
- [Unit]
17
- Description=EmailEngine
18
-
19
- # In some platforms redis could be installed as redis-server.service
20
- # So make sure the service name listed here is valid
21
- After=redis.service
22
-
23
- [Service]
24
- Environment="NODE_ENV=production"
25
-
26
- # --- Configuration ---
27
-
28
- # Optional. Uncomment to use a system specific configuration file outside of the EmailEngine folder.
29
- # Configuration settings from this file are merged with default settings.
30
- #Environment="NODE_CONFIG_PATH=/etc/emailengine.toml"
31
-
32
- # Optional. Uncomment to override configuration values with environment variables
33
- #Environment="EENGINE_REDIS=redis://127.0.0.1:6379/8"
34
- #Environment="EENGINE_HOST=127.0.0.1"
35
- #Environment="EENGINE_PORT=3000"
36
- #Environment="EENGINE_LOG_LEVEL=trace"
37
-
38
- # --- Application ---
39
-
40
- # This is the folder where EmailEngine files reside.
41
-
42
- # NB! If you are using `npx` to run the application then you can ignore this section
43
- # and comment out `WorkingDirectory` as npx manages code files and dependencies itself.
44
-
45
- # Normally this folder would include a clean copy from the EmailEngine Github repository + `npm install --omit=dev`.
46
- # To set up:
47
- # git clone git://github.com/postalsys/emailengine.git
48
- # cd emailengine
49
- # npm install --omit=dev
50
-
51
- # If EmailEngine files are cloned from Github then an easy way to upgrade the application would look like this:
52
- # git pull origin master
53
- # npm install --omit=dev
54
- # And then (as root or a user with sudo privileges):
55
- # sudo systemctl restart emailengine
56
-
57
- WorkingDirectory=/home/deployer/apps/emailengine/
58
-
59
- # --- Service user ---
60
-
61
- # Use non-privileged user to run the app.
62
- # www-data usually already exists in the system but could be any other user as well.
63
- # Make sure this user has read access to application files and, if using
64
- # config file at $NODE_CONFIG_PATH, then to this file as well
65
- User=www-data
66
- Group=www-data
67
-
68
- # --- Execution ---
69
-
70
- # npm location is dependent on platform.
71
- # Use `which npm` to resolve actual path.
72
- ExecStart=/usr/bin/npm start
73
-
74
- # Alternatively you can use `npx` instead of `npm`. This way you would not have to
75
- # manage application files or dependencies manually. For upgrading, just modify
76
- # application version in the following command and run `systemctl daemon-reload && systemctl restart emailengine`
77
- # NB! First start after version change is going to take some time as `npx` has to install all dependencies.
78
- #ExecStart=/usr/bin/npx emailengine@1.2.14
79
-
80
- Type=simple
81
- Restart=always
82
- RestartSec=5
83
-
84
- # Increase limits
85
- # file size, ulimit -f
86
- LimitFSIZE=infinity
87
- # open files, ulimit -n
88
- LimitNOFILE=500000
89
- # processes/threads, ulimit -u
90
- LimitNPROC=500000
91
-
92
- # --- Logging ---
93
-
94
- SyslogIdentifier=emailengine
95
-
96
- [Install]
97
- WantedBy=multi-user.target
@@ -1,77 +0,0 @@
1
- # This example file shows how to configure Nginx to proxy requests to EmailEngine
2
- # NB! Replace all occurrences of emailengine.example.com in this file with your actual domain name.
3
-
4
- # To setup Nginx, if not installed: `apt-get update && apt-get install nginx`
5
-
6
- # Copy this file to /etc/nginx/sites-enabled/emailengine.example.com.conf
7
-
8
- # Once set up run `nginx -t` as root to check for configuration errors
9
- # If no errors were found run `systemctl reload nginx` as root to enable the updated configuration
10
-
11
- server {
12
- # Set up an HTTPS site with HTTP redirect
13
- listen 80;
14
- listen [::]:80;
15
- listen 443 ssl http2;
16
- listen [::]:443 ssl http2;
17
-
18
- # --- Domain name ---
19
- # Make sure to change the domain name
20
- server_name emailengine.example.com;
21
-
22
- # --- HTTP ---
23
- # Redirect all requests against HTTP to HTTPS
24
- if ($scheme != "https") {
25
- return 301 https://$host$request_uri;
26
- }
27
-
28
- # --- HTTPS ---
29
- # Make sure to use valid SSL certificates here, these must exist or Nginx would not start
30
-
31
- # To bootstrap you can generate self signed certificates using the following commands:
32
- # sudo openssl req -subj "/CN=emailengine.example.com/O=My Company Name LTD./C=US" -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout privkey.pem -out fullchain.pem
33
- # sudo chmod 0600 privkey.pem
34
- # sudo mv privkey.pem /etc/ssl/private/emailengine-privkey.pem
35
- # sudo mv fullchain.pem /etc/ssl/certs/emailengine-fullchain.pem
36
-
37
- # Once you have the server running with self signed certs, install https://achme.sh as root and run the following
38
- # to provision a valid and auto-renewing Let's Encrypt certificate that replaces self-signed certs:
39
- # /root/.acme.sh/acme.sh --issue --nginx \
40
- # -d emailengine.example.com \
41
- # --key-file /etc/ssl/private/emailengine-privkey.pem \
42
- # --fullchain-file /etc/ssl/certs/emailengine-fullchain.pem \
43
- # --reloadcmd "/bin/systemctl reload nginx"
44
-
45
- ssl_certificate_key /etc/ssl/private/emailengine-privkey.pem;
46
- ssl_certificate /etc/ssl/certs/emailengine-fullchain.pem;
47
-
48
- # --- PROXY ---
49
- location / {
50
- client_max_body_size 50M;
51
- proxy_http_version 1.1;
52
- proxy_redirect off;
53
- proxy_set_header X-Real-IP $remote_addr;
54
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
55
- proxy_set_header X-Forwarded-Proto https;
56
- proxy_set_header X-Scheme $scheme;
57
- proxy_set_header Host $http_host;
58
- proxy_pass http://127.0.0.1:3000;
59
-
60
- # --- IP whitelist ---
61
- # Uncomment to allow access from specific IP addresses only.
62
- # Addresses not enabled by 'allow' will get a 403 error.
63
- #allow 18.194.223.2/32;
64
- #deny all;
65
-
66
- # --- Basic Auth ---
67
- # Use basic auth to protect from outside access
68
- auth_basic "Restricted Content";
69
- auth_basic_user_file /etc/nginx/.htpasswd-emailengine;
70
-
71
- # To add users to htpasswd file:
72
- # This command creates an incomplete user entry row. Replace 'username' with the user name you want to use
73
- # sudo sh -c "echo -n 'username:' >> /etc/nginx/.htpasswd-emailengine"
74
- # This command appends hashed password to the previously inserted user entry row
75
- # sudo sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd-emailengine"
76
- }
77
- }