--- last_review: "2026-04-15" last_reviewer: "Florian Spreckelsen" documented_code: [ ] --- ```{tags} how-to, linkahead, administrator ``` # Test Email Setup :::{note} This new page has not yet been fully revised. There might be inconsistencies or errors when using with current LinkAhead versions. ::: % TODO: Issue: https://gitlab.indiscale.com/caosdb/src/linkahead-docs/-/work_items/92 ## Overview We will * Start an SMTP server which will receive our emails. * Run tests from the command line. ## Prerequisites * You need to have pylinkahead installed * You need docker ## Steps We run [Mailpit](https://mailpit.axllent.org/) as a local SMTP server which does actually send the mails. 1. Create a docker compose file: ```yaml # ./docker-compose.yml services: mailpit: image: axllent/mailpit:v1.29 command: - "--smtp-tls-cert" - "sans:localhost" - "--smtp-tls-key" - "sans:localhost" ports: - 8025:8025 - 1025:1025 environment: MP_SMTP_REQUIRE_STARTTLS: true #MP_SMTP_REQUIRE_TLS: true #MP_SMTP_AUTH_ACCEPT_ANY: 1 MP_SMTP_AUTH_ALLOW_INSECURE: 0 MP_SMTP_AUTH: "user1:password" ``` 2. Start the STMP server: ```shell docker compose up -d ``` 3. Configure pylinkahead, add an `[Email]` section to your pylinkahead.ini: ``` # ./pylinkahead.ini [Email] smtp_server=localhost smtp_starttls=yes smtp_tls_verify=no smtp_port=1025 smtp_username=user1 smtp_password=password smtp_timeout=1.0 from_address="Test" bcc_append=logger@example.com ``` 4. Run interactive tests from the python REPL: ```shell >>> from linkahead.utils.email import send_email >>> send_email(message="test", subject="subj", to="to@example.com", cc="cc@example.com", bcc="bcc@example.com") ``` 5. Check mails, browse to `http://localhost:8025`. 6. Finally, shut down Mailpit with `docker compose down`. This also deletes all test mails.