Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dolibarr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NoCloud
docker
Dolibarr
Commits
5149e036
Commit
5149e036
authored
8 months ago
by
Elisée Chemin
Browse files
Options
Downloads
Patches
Plain Diff
First SMTP setup php script
parent
927ac4c6
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
docker-compose.yml
+6
-0
6 additions, 0 deletions
docker-compose.yml
docker/Dockerfile
+1
-0
1 addition, 0 deletions
docker/Dockerfile
docker/setupmail.php
+41
-0
41 additions, 0 deletions
docker/setupmail.php
with
48 additions
and
0 deletions
docker-compose.yml
+
6
−
0
View file @
5149e036
...
@@ -34,6 +34,12 @@ services:
...
@@ -34,6 +34,12 @@ services:
LC_ALL
:
${LOCALE}
LC_ALL
:
${LOCALE}
LC_C_TYPE
:
${LOCALE}
LC_C_TYPE
:
${LOCALE}
TZ
:
${TZ}
TZ
:
${TZ}
MAIL_SMTP_HOST
:
${MAIL_SMTP_HOST}
MAIL_SMTP_PORT
:
${MAIL_SMTP_PORT}
MAIL_SENDMODE
:
${MAIL_SENDMODE}
MAIL_SMTP_USER
:
${MAIL_SMTP_USER}
MAIL_SMTP_PASSWORD
:
${MAIL_SMTP_PASSWORD}
MAIL_MAIN_FROM
:
${MAIL_MAIN_FROM}
restart
:
${RESTART}
restart
:
${RESTART}
links
:
links
:
-
mariadb
-
mariadb
This diff is collapsed.
Click to expand it.
docker/Dockerfile
+
1
−
0
View file @
5149e036
...
@@ -67,5 +67,6 @@ RUN sed -i "s/^# *\($LOCALE\)/\1/" /etc/locale.gen && locale-gen
...
@@ -67,5 +67,6 @@ RUN sed -i "s/^# *\($LOCALE\)/\1/" /etc/locale.gen && locale-gen
WORKDIR
/var/www/
WORKDIR
/var/www/
RUN
mkdir
/var/www/custom
RUN
mkdir
/var/www/custom
COPY
setupmail.php /
COPY
entrypoint.sh /
COPY
entrypoint.sh /
ENTRYPOINT
["/entrypoint.sh"]
ENTRYPOINT
["/entrypoint.sh"]
This diff is collapsed.
Click to expand it.
docker/setupmail.php
0 → 100644
+
41
−
0
View file @
5149e036
<?php
define
(
"NOSESSION"
,
1
);
include
"/var/www/dolibarr/htdocs/master.inc.php"
;
// dolibarr
include_once
DOL_DOCUMENT_ROOT
.
"/core/lib/admin.lib.php"
;
// dolibarr_set_const
include_once
DOL_DOCUMENT_ROOT
.
"/core/lib/functions.lib.php"
;
// For sanitizeVal
$errors
=
[];
$setup_vars
=
[
"MAIL_SMTP_HOST"
=>
sanitizeVal
(
getenv
(
"MAIL_SMTP_HOST"
),
'alphanohtml'
),
// MAIN_MAIL_SMTP_SERVER -> IP or HOST
"MAIL_SMTP_PORT"
=>
sanitizeVal
(
getenv
(
"MAIL_SMTP_PORT"
),
'int'
),
// MAIN_MAIL_SMTP_PORT -> 465
"MAIL_SENDMODE"
=>
sanitizeVal
(
getenv
(
"MAIL_SENDMODE"
),
'aZ09'
),
// MAIN_MAIL_SENDMODE -> stmps
"MAIL_SMTPS_USER"
=>
sanitizeVal
(
getenv
(
"MAIL_SMTP_USER"
),
'alphanohtml'
),
// MAIN_MAIL_SMTPS_ID -> robot@domain.com
"MAIL_SMTPS_PASSWORD"
=>
sanitizeVal
(
getenv
(
"MAIL_SMTP_PASSWORD"
),
'none'
),
// MAIN_MAIL_SMTPS_PW -> pw
"MAIL_MAIN_FROM"
=>
sanitizeVal
(
getenv
(
"MAIL_MAIN_FROM"
),
'alphanohtml'
),
// MAIN_MAIL_EMAIL_FROM -> no-reply@domain.com
];
foreach
(
$setup_vars
as
$key
=>
$val
){
if
(
$val
)
continue
;
$errors
[]
=
"Missing value for '
{
$key
}
' !"
;
}
if
(
!
empty
(
$errors
)){
$errcount
=
count
(
$errors
);
print
(
"[MAIL]:
{
$errcount
}
configuration errors:"
);
foreach
(
$errors
as
$errs
){
print
(
"
\t
>"
.
$errors
.
"
\n
"
);
}
}
else
{
dolibarr_set_const
(
$db
,
"MAIN_MAIL_SENDMODE"
,
$setup_vars
[
'MAIL_SENDMODE'
],
'chaine'
,
0
,
''
,
$conf
->
entity
);
dolibarr_set_const
(
$db
,
"MAIN_MAIL_SMTP_PORT"
,
$setup_vars
[
'MAIL_SMTP_PORT'
],
'chaine'
,
0
,
''
,
$conf
->
entity
);
dolibarr_set_const
(
$db
,
"MAIN_MAIL_SMTP_SERVER"
,
$setup_vars
[
'MAIL_SMTP_HOST'
],
'chaine'
,
0
,
''
,
$conf
->
entity
);
dolibarr_set_const
(
$db
,
"MAIN_MAIL_SMTPS_ID"
,
$setup_vars
[
'MAIL_SMTPS_USER'
],
'chaine'
,
0
,
''
,
$conf
->
entity
);
dolibarr_set_const
(
$db
,
"MAIN_MAIL_SMTPS_PW"
,
$setup_vars
[
'MAIL_SMTPS_PASSWORD'
],
'chaine'
,
0
,
''
,
$conf
->
entity
);
// will encrypt the password because the key ends with'PW'
dolibarr_set_const
(
$db
,
"MAIN_MAIL_EMAIL_FROM"
,
$setup_vars
[
'MAIL_MAIN_FROM'
],
'chaine'
,
0
,
''
,
$conf
->
entity
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment