bebleo / smtpdfix

A SMTP server for use as a pytest fixture that implements encryption and authentication.
MIT License
15 stars 5 forks source link

SMTPD_PORT env var does not set port #404

Open chrisg89 opened 4 weeks ago

chrisg89 commented 4 weeks ago

Describe the bug

The documentation states:

Configuration is handled through properties in the config of the fixture and are initially set from environment variables:

But when set the variable SMTPD_PORT in my dockerfile via:

ENV SMTPD_PORT="555"

and then print out the value of smtpd.config.port via:

def test_sendmail(smtpd):
    logging.info(os.environ['SMTPD_HOST'])
    logging.info(os.environ['SMTPD_PORT'])
    logging.info(smtpd.config.host)
    logging.info(smtpd.config.port)

I get

INFO     root:test.py:201 xxx
INFO     root:test.py:202 555
INFO     root:test.py:203 xxx
INFO     root:test.py:204 43341

In summary, the content of SMTPD_PORT is ignored and a random free port is used instead.

To Reproduce Set the env var SMTPD_PORT before launching the script. Launch the script

Expected behavior The port specified in SMTPD_PORT should be used instead of a random free port.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

bebleo commented 4 weeks ago

Hi @chrisg89,

Thanks for taking the time to report this bug.

I won't have time to work on it until the weekend, but will try to get to it then. If in the meantime you want to submit a PR fixing the issue I'd be happy to review and publish a release.