Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
365a01ca
Commit
365a01ca
authored
7 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Use warning level when /etc/mailname seems to be not correct.
parent
8008cee2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_email.py
+18
-22
18 additions, 22 deletions
tests/test_email.py
with
18 additions
and
22 deletions
tests/test_email.py
+
18
−
22
View file @
365a01ca
...
...
@@ -41,16 +41,10 @@ def check_listening_port():
status
,
out
=
subprocess
.
getstatusoutput
(
'
netstat -pant | grep master | grep 127.0.0.1:25
'
)
if
status
!=
0
:
print_red
(
'
The port 25 is not listened by postfix
"
master
"
process.
'
)
return
False
return
1
else
:
print_green
(
'
Postfix is listening port 25 correctly.
'
)
return
True
def
check_spf
(
ip
):
status
,
output
=
subprocess
.
getstatusoutput
(
'
host -t TXT ubicast.eu
'
)
if
ip
in
output
:
return
True
return
0
def
check_relay
():
...
...
@@ -62,7 +56,6 @@ def check_relay():
configured_relay
=
None
if
not
configured_relay
:
# no relay configured, check relayless situations
# domain = '.'.join(conf.get('MS_SERVER_NAME').split('.')[-2:])
ip
=
conf
.
get
(
'
NETWORK_IP_NAT
'
)
if
not
ip
:
ip
=
conf
.
get
(
'
NETWORK_IP
'
)
...
...
@@ -70,17 +63,19 @@ def check_relay():
d
=
f
.
read
().
strip
()
if
d
not
in
(
'
ubicast.tv
'
,
'
ubicast.eu
'
):
print_red
(
'
/etc/mailname does not contain ubicast.eu or ubicast.tv, mails will probably not be received on ubicast mailing lists
'
)
return
False
if
not
check_spf
(
ip
):
return
2
# check spf
status
,
output
=
subprocess
.
getstatusoutput
(
'
host -t TXT ubicast.eu
'
)
if
ip
not
in
output
:
print_red
(
'
ip %s is not in ubicast.eu SPF and emails sent from support@ubicast.eu will be treated as spam
'
%
ip
)
return
False
return
1
conf_relay
=
conf
.
get
(
'
EMAIL_SMTP_SERVER
'
)
if
conf_relay
!=
configured_relay
:
print_red
(
'
Configured STMP relay (%s) does not match the expected value (%s).
'
%
(
configured_relay
,
conf_relay
))
return
False
return
1
else
:
print_green
(
'
STMP relay is properly set.
'
)
return
True
return
1
def
send_test_email
():
...
...
@@ -97,23 +92,24 @@ def send_test_email():
if
status
!=
0
:
print_red
(
'
Failed to send email.
'
)
print
(
'
No log entry found using command: %s
'
%
cmd
)
return
False
return
1
if
'
bounced
'
not
in
out
or
'
The email account that you tried to reach does not exist.
'
in
out
:
print_green
(
'
Email sent.
'
)
return
True
return
0
else
:
print_red
(
'
Failed to send email.
'
)
print
(
'
Sending log line:
\n
%s
'
%
out
)
return
False
return
1
if
not
os
.
path
.
exists
(
'
/etc/postfix
'
):
print_red
(
'
Postfix dir does not exists, please install postfix.
'
)
sys
.
exit
(
1
)
all_ok
=
check_listening_port
()
if
all_ok
:
all_ok
=
all_ok
and
check_relay
()
all_ok
=
all_ok
and
send_test_email
()
rc
=
check_listening_port
()
if
rc
==
0
:
rc
=
check_relay
()
if
send_test_email
()
==
1
:
rc
=
1
sys
.
exit
(
int
(
not
all_ok
)
)
sys
.
exit
(
rc
)
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