Skip to content

Commit 747265f

Browse files
committed
admin_mail placeholder in mail user welcome email
1 parent aee0071 commit 747265f

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From: ISPConfig <postmaster@localhost.localdomain>
1+
From: {admin_name} <{admin_mail}>
22
Subject: Ihr Mailaccount ist aktiv.
33

4-
Ihr Mailaccount ist jetzt aktiv. Viel Vergnügen.
4+
Ihr Mailaccount ist jetzt aktiv. Viel Vergnügen.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From: ISPConfig <postmaster@localhost.localdomain>
1+
From: {admin_name} <{admin_mail}>
22
Subject: Welcome to your new email account.
33

4-
Welcome to your new email account. Your webmaster.
4+
Welcome to your new email account. Your webmaster.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From: ISPConfig <postmaster@localhost.localdomain>
1+
From: {admin_name} <{admin_mail}>
22
Subject: Bienvenido a su nueva cuenta de correo
33

44
Bienvenido a su nueva cuenta de correo. Su administrador.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From: ISPConfig <postmaster@localhost.localdomain>
1+
From: {admin_name} <{admin_mail}>
22
Subject: Bienvenue dans votre nouvelle boîte aux lettres
33

44
Votre nouveau compte email est désormais activé. Votre webmaster.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From: ISPConfig <postmaster@localhost.localdomain>
1+
From: {admin_name} <{admin_mail}>
22
Subject: Dobrodošli u vaš novi email račun.
33

4-
Dobrodošli u vaš novi email račun. Vaš webmajstor.
4+
Dobrodošli u vaš novi email račun. Vaš webmajstor.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From: ISPConfig <postmaster@localhost.localdomain>
1+
From: {admin_name} <{admin_mail}>
22
Subject: Welkom in uw nieuwe account.
33

44
Welkom in uw nieuwe email account. Uw webmaster.

server/plugins-available/mail_plugin.inc.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ function user_insert($event_name, $data) {
8282
//* get the config
8383
$app->uses('getconf,system');
8484
$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
85+
$global_mail_config = $app->getconf->get_global_config('mail');
8586

8687
// convert to lower case - it could cause problems if some directory above has upper case name
8788
// $data['new']['maildir'] = strtolower($data['new']['maildir']);
@@ -218,20 +219,30 @@ function user_insert($event_name, $data) {
218219
$lines = file($conf['rootpath'].'/conf/mail/welcome_email_en.txt');
219220
}
220221

222+
$placeholders = array(
223+
'{domain}' => "$domain",
224+
'{email}' => $data["new"]["email"],
225+
'{admin_mail}' => ($global_mail_config['admin_mail'] != '' ? $global_mail_config['admin_mail'] : 'root'),
226+
'{admin_name}' => ($global_mail_config['admin_name'] != '' ? $global_mail_config['admin_name'] : ''),
227+
);
228+
221229
//* Get from address
222230
$parts = explode(':', trim($lines[0]));
223231
unset($parts[0]);
224232
$welcome_mail_from = implode(':', $parts);
225233
unset($lines[0]);
234+
$welcome_mail_from = strtr($welcome_mail_from, $placeholders);
226235

227236
//* Get subject
228237
$parts = explode(':', trim($lines[1]));
229238
unset($parts[0]);
230239
$welcome_mail_subject = implode(':', $parts);
231240
unset($lines[1]);
241+
$welcome_mail_subject = strtr($welcome_mail_subject, $placeholders);
232242

233243
//* Get message
234244
$welcome_mail_message = trim(implode($lines));
245+
$welcome_mail_message = strtr($welcome_mail_message, $placeholders);
235246
unset($tmp);
236247

237248
$mailHeaders = "MIME-Version: 1.0" . "\n";
@@ -247,8 +258,14 @@ function user_insert($event_name, $data) {
247258
$mailTarget = $data["new"]["email"];
248259
$mailSubject = "=?utf-8?B?".base64_encode($welcome_mail_subject)."?=";
249260

250-
//* Send the welcome email only on the "master" mail server to avoid duplicate emails
251-
if($conf['mirror_server_id'] == 0) mail($mailTarget, $mailSubject, $welcome_mail_message, $mailHeaders);
261+
$additionalParameters = '';
262+
if (preg_match('/\b([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,63})\b/i', $welcome_mail_from, $matches)) {
263+
$additionalParameters = '-f '.$matches[1];
264+
}
265+
266+
// Send the welcome email only on a "master" mail server to avoid duplicate emails
267+
// (bypass the normal ispcmail class when creating mail accounts)
268+
if($conf['mirror_server_id'] == 0) mail($mailTarget, $mailSubject, $welcome_mail_message, $mailHeaders, $additionalParameters);
252269

253270
}
254271

0 commit comments

Comments
 (0)