Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Openslides MV Tools
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Nico
Openslides MV Tools
Commits
1e300b0f
Verified
Commit
1e300b0f
authored
1 year ago
by
Nico
Browse files
Options
Downloads
Patches
Plain Diff
add sendmail script
parent
5ab23da8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sendmail.py
+36
-0
36 additions, 0 deletions
sendmail.py
with
36 additions
and
0 deletions
sendmail.py
0 → 100755
+
36
−
0
View file @
1e300b0f
#!/usr/bin/python3
import
smtplib
from
email.message
import
EmailMessage
import
argparse
ap
=
argparse
.
ArgumentParser
()
ap
.
add_argument
(
"
--recipients
"
,
type
=
argparse
.
FileType
(
'
r
'
),
help
=
"
Recipients, one per line
"
,
required
=
True
)
ap
.
add_argument
(
"
--message
"
,
type
=
argparse
.
FileType
(
'
r
'
),
help
=
"
Message to send
"
,
required
=
True
)
ap
.
add_argument
(
"
--subject
"
,
help
=
"
Message subject
"
,
required
=
True
)
ap
.
add_argument
(
"
--sender
"
,
help
=
"
Mail from
"
,
required
=
True
)
args
=
ap
.
parse_args
()
message
=
args
.
message
.
read
()
for
line
in
args
.
recipients
:
if
line
.
startswith
(
"
#
"
):
continue
if
not
"
@
"
in
line
:
print
(
f
"
Line does not seem to contain @-sign:
{
line
}
"
)
recipient
=
line
.
strip
()
if
len
(
line
)
<
1
:
continue
print
(
f
"
Sending to
{
recipient
}
...
"
)
msg
=
EmailMessage
()
msg
.
set_content
(
message
)
msg
[
'
Subject
'
]
=
args
.
subject
msg
[
'
From
'
]
=
args
.
sender
msg
[
'
To
'
]
=
recipient
# Send the message via our own SMTP server.
s
=
smtplib
.
SMTP
(
'
localhost
'
)
s
.
send_message
(
msg
)
s
.
quit
()
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