Skip to content

Commit

Permalink
Rydder i epostfunksjonen
Browse files Browse the repository at this point in the history
  • Loading branch information
danmichaelo committed May 6, 2016
1 parent 8d6f439 commit 49dbb6d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lokar.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,11 @@ def parse_args(args):
return args


def email(domain, api_key, sender, recipient, subject, body):
request_url = 'https://api.mailgun.net/v2/{0}/messages'.format(domain)
request = requests.post(request_url, auth=('api', api_key), data={
'from': sender,
'to': recipient,
def email(subject, body, config):
request_url = 'https://api.mailgun.net/v2/{0}/messages'.format(config['mailgun.domain'])
request = requests.post(request_url, auth=('api', config['mailgun.api_key']), data={
'from': config['mailgun.sender'],
'to': config['mailgun.recipient'],
'subject': subject,
'text': body
})
Expand Down Expand Up @@ -432,8 +432,7 @@ def main(config=None, args=None):
if not args.dry_run:
subject = '[{}] "{}" → "{}" endret i {:d} post(er)'.format(args.tag, old_term, new_term, len(valid_records))
body = log_capture_string.getvalue()
email(domain=config['mailgun.domain'], api_key=config['mailgun.api_key'], sender=config['mailgun.sender'],
recipient=config['mailgun.recipient'], subject=subject, body=body)
email(subject, body, config)

return valid_records

Expand Down

0 comments on commit 49dbb6d

Please sign in to comment.