Skip to content

Commit

Permalink
Merge pull request #11 from jakewaldron/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jakewaldron committed Jan 8, 2016
2 parents d889c14 + ded9238 commit 6e2d03b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ The config file is in the scripts folder. Before first run of the script, pleas

#####Web
* web_enabled - Enable the creation of the web page
* web_only_save_images - Will not create the index.html, but will still save images to the image folder.
* web_domain - Domain name of the web page
* web_path - Path on the domain to the web page
* web_delete_previous_images - True to delete all .jpg images in the web image folder prior to copying over current images
Expand All @@ -109,6 +110,7 @@ The config file is in the scripts folder. Before first run of the script, pleas
* email_use_bcc - True to send emails on using bcc instead of to (email_to settings will send to them using bcc)
* email_to - Array of email addresses to send the email
* email_to_send_to_shared_users - True to get list of shared user emails (plex_username and plex_password must be valid for this to be used)
* email_unsubscribe - List of emails to exclude (emails in email_to will override emails in this)
* email_from - Email address to send the email from
* email_from_name - Friendly name of sender
* email_smtp_address - SMTP address of the email service
Expand Down Expand Up @@ -220,4 +222,4 @@ TV Seasons:
![alt tag](http://i.imgur.com/fF7HNL4.jpg)

TV Episodes:
![alt tag](http://i.imgur.com/xiwUNPT.jpg)
![alt tag](http://i.imgur.com/xiwUNPT.jpg)
1 change: 1 addition & 0 deletions scripts/config.conf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ email_use_bcc = False
email_to = ['']
#This requires plex_username and plex_password to be filled to get emails of shared users.
email_to_send_to_shared_users = False
email_unsubscribe = ['']
email_from = ''
email_from_name = 'Plex Server'
email_smtp_address = 'smtp.gmail.com'
Expand Down
21 changes: 15 additions & 6 deletions scripts/plexEmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

def replaceConfigTokens():
## The below code is for backwards compatibility
if ('email_unsubscribe' not in config):
config['email_unsubscribe'] = []

if ('email_use_bcc' not in config):
config['email_use_bcc'] = False

Expand Down Expand Up @@ -319,6 +322,10 @@ def addheader(message, headername, headervalue):
return message

def sendMail(email):
#First check if email is in the unsubscribe list
if email != '' and email[0].upper() in (name.upper() for name in config['email_unsubscribe']):
print email[0] + ' is in the unsubscribe list. Do not send an email.'
return 0;
gmail_user = config['email_username']
gmail_pwd = config['email_password']
smtp_address = config['email_smtp_address']
Expand Down Expand Up @@ -375,6 +382,8 @@ def sendMail(email):
server.login(gmail_user, gmail_pwd)
server.sendmail(FROM, TO, msg.as_string())
server.close()

return 1;

def createEmailHTML():
emailText = """<!DOCTYPE html>
Expand Down Expand Up @@ -1044,16 +1053,16 @@ def createWebHTML():

emailCount = 0
if (testMode):
sendMail([config['email_from']])
emailCount += 1
success = sendMail([config['email_from']])
emailCount += success
elif (config['email_individually']):
for emailAdd in config['email_to']:
email = [emailAdd]
sendMail(email)
emailCount += 1
success = sendMail(email)
emailCount += success
else:
sendMail('')
emailCount += 1
success = sendMail('')
emailCount += success
print 'Successfully sent %s email(s)' % emailCount
# except:
# print "Failed to send email(s)"
Expand Down

0 comments on commit 6e2d03b

Please sign in to comment.