Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
3pia
VISPA
VISPA web
Commits
e5c1f5d3
Commit
e5c1f5d3
authored
Jul 16, 2015
by
Gero Müller
Browse files
fix mail sending
(transplanted from f2e0374024d9d85f77cacb58c8a0b9029ed1ac1c)
parent
2d788e8a
Changes
1
Hide whitespace changes
Inline
Side-by-side
vispa/__init__.py
View file @
e5c1f5d3
...
...
@@ -298,6 +298,13 @@ def send_mail(addr, subject="", content="", sender_addr=None, smtp_host=None,
and UTF-8 that can represent all the characters occurring in the email.
"""
if
smtp_host
is
None
:
smtp_host
=
config
(
"mail"
,
"smtp.host"
,
"localhost"
)
if
smtp_port
is
None
:
smtp_host
=
config
(
"mail"
,
"smtp.port"
,
0
)
if
sender_addr
is
None
:
sender_addr
=
config
(
"mail"
,
"sender_address"
,
"noreply@example.org"
)
# Header class is smart enough to try US-ASCII, then the charset we
# provide, then fall back to UTF-8.
header_charset
=
'ISO-8859-1'
...
...
@@ -331,7 +338,7 @@ def send_mail(addr, subject="", content="", sender_addr=None, smtp_host=None,
msg
[
'Subject'
]
=
Header
(
unicode
(
subject
),
header_charset
)
# Send the message via SMTP to localhost:25
smtp
=
SMTP
(
"localhost"
)
smtp
=
SMTP
(
smtp_host
,
smtp_port
)
smtp
.
sendmail
(
sender_addr
,
addr
,
msg
.
as_string
())
smtp
.
quit
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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