diff --git a/README.md b/README.md index eff4bad..5eb9469 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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) \ No newline at end of file diff --git a/scripts/config.conf b/scripts/config.conf index 3ec6581..fb6f260 100644 --- a/scripts/config.conf +++ b/scripts/config.conf @@ -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' diff --git a/scripts/plexEmail.py b/scripts/plexEmail.py index 7513719..4c9ba46 100644 --- a/scripts/plexEmail.py +++ b/scripts/plexEmail.py @@ -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 @@ -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'] @@ -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 = """ @@ -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)"