Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mailinabox
Commits
acaa29e8
Commit
acaa29e8
authored
Sep 01, 2013
by
Joshua Tauberer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mail.py: check that mailboxes don't exist before creating them
parent
5b82bbb5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
mail.py
tools/mail.py
+10
-3
No files found.
tools/mail.py
View file @
acaa29e8
...
...
@@ -48,10 +48,17 @@ elif sys.argv[1] == "user" and sys.argv[2] in ("add", "password"):
print
(
"User already exists."
)
sys
.
exit
(
1
)
# Create the user's INBOX and subscribe it.
conn
.
commit
()
# write it before next step
subprocess
.
check_call
([
"doveadm"
,
"mailbox"
,
"create"
,
"-u"
,
email
,
"-s"
,
"INBOX"
])
subprocess
.
check_call
([
"doveadm"
,
"mailbox"
,
"create"
,
"-u"
,
email
,
"-s"
,
"Spam"
])
# Create the user's INBOX and Spam folders and subscribe them.
# Check if the mailboxes exist before creating them. When creating a user that had previously
# been deleted, the mailboxes will still exist because they are still on disk.
existing_mboxes
=
subprocess
.
check_output
([
"doveadm"
,
"mailbox"
,
"list"
,
"-u"
,
email
,
"-8"
])
.
decode
(
"utf8"
)
.
split
(
"
\n
"
)
if
"INBOX"
not
in
existing_mboxes
:
subprocess
.
check_call
([
"doveadm"
,
"mailbox"
,
"create"
,
"-u"
,
email
,
"-s"
,
"INBOX"
])
if
"Spam"
not
in
existing_mboxes
:
subprocess
.
check_call
([
"doveadm"
,
"mailbox"
,
"create"
,
"-u"
,
email
,
"-s"
,
"Spam"
])
elif
sys
.
argv
[
2
]
==
"password"
:
c
.
execute
(
"UPDATE users SET password=? WHERE email=?"
,
(
pw
,
email
))
if
c
.
rowcount
!=
1
:
...
...
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