Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sick-Beard
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
Sick-Beard
Commits
e085b08d
Commit
e085b08d
authored
May 23, 2013
by
CREMEL Stéphane
Browse files
Options
Downloads
Patches
Plain Diff
Add mail Notifier
parent
54f33a35
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sickbeard/notifiers/mail.py
+91
-0
91 additions, 0 deletions
sickbeard/notifiers/mail.py
with
91 additions
and
0 deletions
sickbeard/notifiers/mail.py
0 → 100644
+
91
−
0
View file @
e085b08d
# Author: Stephane CREMEL <stephane.cremel@gmail.com>
#
# This file is part of Sick Beard.
#
# Sick Beard is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Sick Beard is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
import
os
import
subprocess
import
sickbeard
from
sickbeard
import
logger
from
sickbeard
import
encodingKludge
as
ek
from
sickbeard.exceptions
import
ex
from
email.mime.text
import
MIMEText
import
smtplib
class
MailNotifier
:
def
test_notify
(
self
,
mail_from
=
None
,
mail_to
=
None
,
mail_server
=
None
,
mail_ssl
=
None
,
mail_username
=
None
,
mail_password
=
None
):
return
self
.
_notifyMail
(
"
This is a test notification from SickBeard
"
,
"
SickBeard message
"
,
mail_from
,
mail_to
,
mail_server
,
mail_ssl
,
mail_username
,
mail_password
)
def
notify_snatch
(
self
,
ep_name
):
logger
.
log
(
"
Notification MAIL SNATCH
"
,
logger
.
DEBUG
)
if
sickbeard
.
MAIL_NOTIFY_ONSNATCH
:
message
=
str
(
ep_name
)
return
self
.
_notifyMail
(
"
SickBeard Snatch
"
,
message
,
None
,
None
,
None
,
None
,
None
,
None
)
else
:
return
def
notify_download
(
self
,
ep_name
):
logger
.
log
(
"
Notification MAIL SNATCH
"
,
logger
.
DEBUG
)
message
=
str
(
ep_name
)
return
self
.
_notifyMail
(
"
SickBeard Download
"
,
message
,
None
,
None
,
None
,
None
,
None
,
None
)
def
notify_subtitle_download
(
self
,
ep_name
,
lang
):
pass
def
_notifyMail
(
self
,
title
,
message
,
mail_from
=
None
,
mail_to
=
None
,
mail_server
=
None
,
mail_ssl
=
None
,
mail_username
=
None
,
mail_password
=
None
):
if
not
sickbeard
.
USE_MAIL
:
logger
.
log
(
"
Notification for Mail not enabled, skipping this notification
"
,
logger
.
DEBUG
)
return
False
logger
.
log
(
"
Sending notification Mail
"
,
logger
.
DEBUG
)
if
not
mail_from
:
mail_from
=
sickbeard
.
MAIL_FROM
if
not
mail_to
:
mail_to
=
sickbeard
.
MAIL_TO
if
not
mail_ssl
:
mail_ssl
=
sickbeard
.
MAIL_SSL
if
not
mail_server
:
mail_server
=
sickbeard
.
MAIL_SERVER
if
not
mail_username
:
mail_username
=
sickbeard
.
MAIL_USERNAME
if
not
mail_password
:
mail_password
=
sickbeard
.
MAIL_PASSWORD
if
mail_ssl
:
mailserver
=
smtplib
.
SMTP_SSL
(
mail_server
)
else
:
mailserver
=
smtplib
.
SMTP
(
mail_server
)
if
len
(
mail_username
)
>
0
:
mailserver
.
login
(
mail_username
,
mail_password
)
message
=
MIMEText
(
message
)
message
[
'
Subject
'
]
=
title
message
[
'
From
'
]
=
mail_from
message
[
'
To
'
]
=
mail_to
mailserver
.
sendmail
(
mail_from
,
mail_to
,
message
.
as_string
())
return
True
notifier
=
MailNotifier
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