Exemplo n.º 1
0
def send_template(sender,
                  recipient,
                  template,
                  template_data,
                  smtp_server='smtp.gmail.com',
                  smtp_port=587):
    if args.dry_run:
        print 'Dry run -> not sending mail to %s' % recipient
    else:
        get_password(sender['login'])
        print '-> %s' % recipient

    template_data['email'] = recipient
    message = _from_template('../mail/templates/' + template, template_data)

    if args.dry_run:
        print "=" * 80
        print message
        print "=" * 80

        return

    session = smtplib.SMTP(smtp_server, smtp_port)

    session.ehlo()
    session.starttls()
    session.ehlo
    session.login(sender['login'], password)

    session.sendmail(sender['name'], recipient, message)
    session.quit()
Exemplo n.º 2
0
def send_template(sender, recipient, template, template_data,
                  smtp_server='smtp.gmail.com', smtp_port=587):
    if args.dry_run:
        print 'Dry run -> not sending mail to %s' % recipient
    else:
        get_password(sender['login'])
        print '-> %s' % recipient

    template_data['email'] = recipient
    message = _from_template('../mail/templates/' + template, template_data)

    if args.dry_run:
        print "=" * 80
        print message
        print "=" * 80

        return

    session = smtplib.SMTP(smtp_server, smtp_port)

    session.ehlo()
    session.starttls()
    session.ehlo
    session.login(sender['login'], password)

    session.sendmail(sender['name'], recipient, message)
    session.quit()
Exemplo n.º 3
0
def from_template(tmpl_basename, config, dest_fn):

    outfile = _from_template(tmpl_basename, config)
    extension = os.path.splitext(dest_fn)[1][1:]
    outname = os.path.join(build_dir, extension, dest_fn)

    with open(outname, mode='w') as f:
        f.write(outfile)
Exemplo n.º 4
0
def from_template(tmpl_basename, config, dest_fn):

    outfile = _from_template(tmpl_basename, config)
    extension = os.path.splitext(dest_fn)[1][1:]
    outname = os.path.join(build_dir, extension, dest_fn)

    with open(outname, mode='w') as f:
        f.write(outfile)
Exemplo n.º 5
0
def html_from_tmpl(src, config, target):

    header = get_html_header(config)
    content =  _from_template(src, config)

    outfile = header+content
    dest_fn = os.path.join(html_dir, target + '.html')
    extension = os.path.splitext(dest_fn)[1][1:]
    outname = os.path.join(build_dir, extension, dest_fn)
    with open(outname, mode='w') as f:
        f.write(outfile)
Exemplo n.º 6
0
def html_from_tmpl(src, config, target):

    header = get_html_header(config)
    content = _from_template(src, config)

    outfile = header + content
    dest_fn = os.path.join(html_dir, target + '.html')
    extension = os.path.splitext(dest_fn)[1][1:]
    outname = os.path.join(build_dir, extension, dest_fn)
    with open(outname, mode='w') as f:
        f.write(outfile)
Exemplo n.º 7
0
 def make_email(self, sender: str, data: t.Dict) -> EmailMessage:
     email = EmailMessage()
     body: str = _from_template("../mail/templates/" + self.template_path,
                                data)
     email.set_content(body)
     email["From"] = sender
     if "to_emails" in data:
         email["To"] = ", ".join([s for s in data["to_emails"] if s])
     if "cc_emails" in data:
         email["CC"] = ", ".join([s for s in data["cc_emails"] if s])
     if "subject" in data:
         email["Subject"] = data["subject"]
     return email
Exemplo n.º 8
0
def get_html_content(tmpl, config):
    return _from_template(tmpl, config)
Exemplo n.º 9
0
def get_html_header(config):
    return _from_template('header.html', config)
Exemplo n.º 10
0
def get_html_content(tmpl, config):
    return _from_template(tmpl, config)
Exemplo n.º 11
0
def get_html_header(config):
    return _from_template('header.html', config)
Exemplo n.º 12
0
for reviewer_info in config['reviewers']:
    for p in reviewer_info['papers']:
        if not os.path.isdir(os.path.join(work_dir, '../papers/', p)):
            raise RuntimeError("Paper %s not found..refusing to generate emails." % p)

if not dry_run:
    password = getpass.getpass(config['sender']['login']+"'s password:  "******"Sending invite to " + reviewer

    msg = _from_template('reviewer-invite.txt', reviewer_config)
    if dry_run:
        print "=" * 78
        print msg
        print "=" * 78
    else:
        gmail.sendmail(config['sender'], reviewer + ', ' + config['cced'],
                       msg, password)

paper_reviewers = {}
for reviewer_info in config['reviewers']:
    for paper in reviewer_info['papers']:
        d = paper_reviewers.setdefault(paper, [])
        d.append(reviewer_info['name'])

for paper in paper_reviewers:
Exemplo n.º 13
0
for reviewer_info in config['reviewers']:
    for p in reviewer_info['papers']:
        if not os.path.isdir(os.path.join(work_dir, '../papers/', p)):
            raise RuntimeError(
                "Paper %s not found..refusing to generate emails." % p)

if not dry_run:
    password = getpass.getpass(config['sender']['login'] + "'s password:  "******"Sending invite to " + reviewer

    msg = _from_template('reviewer-invite.txt', reviewer_config)
    if dry_run:
        print "=" * 78
        print msg
        print "=" * 78
    else:
        gmail.sendmail(config['sender'], reviewer + ', ' + config['cced'], msg,
                       password)

paper_reviewers = {}
for reviewer_info in config['reviewers']:
    for paper in reviewer_info['papers']:
        d = paper_reviewers.setdefault(paper, [])
        d.append(reviewer_info['name'])

for paper in paper_reviewers: