Skip to content
Snippets Groups Projects
Select Git revision
  • c5c153855a9ff9fd384d66d58fc652e0fd2e29de
  • master default
  • wip-slh-dsa-sha2-128s
  • master-updates
  • release-3.10-fixes
  • getopt-prototype
  • fix-bcrypt-warning
  • refactor-hmac
  • wip-use-alignas
  • trim-sha3-context
  • fix-gitlab-ci
  • check-fat-emulate
  • delete-digest_func-size
  • slh-dsa-shake-128f-nettle
  • slh-dsa-shake-128s-nettle
  • slh-dsa-shake-128s
  • delete-openpgp
  • ppc64-sha512
  • delete-md5-compat
  • cleanup-hmac-tests
  • ppc64-sha256
  • nettle_3.10.2_release_20250626
  • nettle_3.10.1_release_20241230
  • nettle_3.10_release_20240616
  • nettle_3.10rc2
  • nettle_3.10rc1
  • nettle_3.9.1_release_20230601
  • nettle_3.9_release_20230514
  • nettle_3.8.1_release_20220727
  • nettle_3.8_release_20220602
  • nettle_3.7.3_release_20210606
  • nettle_3.7.2_release_20210321
  • nettle_3.7.1_release_20210217
  • nettle_3.7_release_20210104
  • nettle_3.7rc1
  • nettle_3.6_release_20200429
  • nettle_3.6rc3
  • nettle_3.6rc2
  • nettle_3.6rc1
  • nettle_3.5.1_release_20190627
  • nettle_3.5_release_20190626
41 results

buffer-init.c

Blame
  • main.py 1.40 KiB
    #!/usr/bin/env python3
    
    import smtpd
    import asyncore
    from email import message_from_bytes
    import email.policy
    from dateutil.parser import parse
    import subprocess
    import re
    
    class CustomSMTPServer(smtpd.SMTPServer):
        def process_message(self, peer, mailfrom, rcpttos, data, **kwargs):
            msg = message_from_bytes(data, policy=email.policy.default)
            body = msg.get_content()
            d = parse(msg.get('Date'))
            title = msg.get('Subject')
    
            if not title:
                print("Title missing")
                return
    
            valid_destinations = [
                    'massutskick@vastgota.nation.liu.se',
                    'massutskick@vastgota.lysator.liu.se',
                    ]
    
            for destination in valid_destinations:
                if destination in msg.get('To'):
                    break
            else:
                print('Will only publish massutskick')
                return
    
            title = re.sub('^\[.*\] *', '', title)
    
            subprocess.run(['wp', 'post', 'create',
                    '--post_author=2'
                    f'--post_date={d:%Y-%m-%d}',
                    f"--post_title={title}",
                    '--post_status=publish',
                    '--post_category=Veckomail',
                    f"--post_content=<pre>{body}</pre>"],
                    cwd='/usr/share/wordpress',
                    shell=False)
            return
    
    
    server = CustomSMTPServer(('0.0.0.0', 1025), None,
            decode_data=False)
    asyncore.loop()