|
24 | 24 |
|
25 | 25 | def replaceConfigTokens(): |
26 | 26 | ## The below code is for backwards compatibility |
| 27 | + if ('email_unsubscribe' not in config): |
| 28 | + config['email_unsubscribe'] = [] |
| 29 | + |
27 | 30 | if ('email_use_bcc' not in config): |
28 | 31 | config['email_use_bcc'] = False |
29 | 32 |
|
@@ -319,6 +322,10 @@ def addheader(message, headername, headervalue): |
319 | 322 | return message |
320 | 323 |
|
321 | 324 | def sendMail(email): |
| 325 | + #First check if email is in the unsubscribe list |
| 326 | + if email != '' and email[0].upper() in (name.upper() for name in config['email_unsubscribe']): |
| 327 | + print email[0] + ' is in the unsubscribe list. Do not send an email.' |
| 328 | + return 0; |
322 | 329 | gmail_user = config['email_username'] |
323 | 330 | gmail_pwd = config['email_password'] |
324 | 331 | smtp_address = config['email_smtp_address'] |
@@ -375,6 +382,8 @@ def sendMail(email): |
375 | 382 | server.login(gmail_user, gmail_pwd) |
376 | 383 | server.sendmail(FROM, TO, msg.as_string()) |
377 | 384 | server.close() |
| 385 | + |
| 386 | + return 1; |
378 | 387 |
|
379 | 388 | def createEmailHTML(): |
380 | 389 | emailText = """<!DOCTYPE html> |
@@ -1044,16 +1053,16 @@ def createWebHTML(): |
1044 | 1053 |
|
1045 | 1054 | emailCount = 0 |
1046 | 1055 | if (testMode): |
1047 | | - sendMail([config['email_from']]) |
1048 | | - emailCount += 1 |
| 1056 | + success = sendMail([config['email_from']]) |
| 1057 | + emailCount += success |
1049 | 1058 | elif (config['email_individually']): |
1050 | 1059 | for emailAdd in config['email_to']: |
1051 | 1060 | email = [emailAdd] |
1052 | | - sendMail(email) |
1053 | | - emailCount += 1 |
| 1061 | + success = sendMail(email) |
| 1062 | + emailCount += success |
1054 | 1063 | else: |
1055 | | - sendMail('') |
1056 | | - emailCount += 1 |
| 1064 | + success = sendMail('') |
| 1065 | + emailCount += success |
1057 | 1066 | print 'Successfully sent %s email(s)' % emailCount |
1058 | 1067 | # except: |
1059 | 1068 | # print "Failed to send email(s)" |
|
0 commit comments