Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Projects
Groups
Snippets
Sign up now
Login
Sign in
Toggle navigation
Menu
Open sidebar
protokollsystem
proto3
Commits
c891012f
Commit
c891012f
authored
Jun 29, 2018
by
Thomas Schneider
Browse files
Use library-provided methods to generate Message-ID header
parent
0b81e059
Changes
1
Hide whitespace changes
Inline
Side-by-side
utils.py
View file @
c891012f
...
...
@@ -7,12 +7,11 @@ import smtplib
from
email.mime.multipart
import
MIMEMultipart
from
email.mime.text
import
MIMEText
from
email.mime.application
import
MIMEApplication
from
email.utils
import
make_msgid
from
datetime
import
datetime
import
requests
from
io
import
BytesIO
import
ipaddress
from
socket
import
getfqdn
from
uuid
import
uuid4
import
subprocess
import
contextlib
...
...
@@ -59,6 +58,8 @@ class MailManager:
self
.
password
=
getattr
(
config
,
"MAIL_PASSWORD"
,
""
)
self
.
use_tls
=
getattr
(
config
,
"MAIL_USE_TLS"
,
True
)
self
.
use_starttls
=
getattr
(
config
,
"MAIL_USE_STARTTLS"
,
False
)
# if SERVER_NAME is empty, we already have problems elsewhere
self
.
msgid_domain
=
getattr
(
config
,
"SERVER_NAME"
)
def
_get_smtp
(
self
):
if
self
.
use_tls
:
...
...
@@ -88,7 +89,7 @@ class MailManager:
msg
[
"From"
]
=
self
.
from_addr
msg
[
"To"
]
=
to_addr
msg
[
"Subject"
]
=
subject
msg
[
"Message-ID"
]
=
"<{}@{}>"
.
format
(
uuid4
(),
getfqdn
()
)
msg
[
"Message-ID"
]
=
make_msgid
(
idstring
=
"proto3"
,
domain
=
self
.
msgid_domain
)
if
reply_to
is
not
None
:
msg
[
"Reply-To"
]
=
reply_to
msg
.
attach
(
MIMEText
(
content
,
_charset
=
"utf-8"
))
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment