Opendkim not signing emails from Flask application

57 Views Asked by At

I have created a Python application to send emails. I am running Python 3.8, Postfix, and Opendkim all on the same Ubuntu 20.04 machine. I have successfully configured Postfix and Opendkim to sign outgoing emails. My Python script is using smtplib to send the emails. This portion is working as expected, and all emails sent from this Python application are signed by Opendkim.

Now, I have created a web API using Flask to send emails. I send some json with a post request to the end point, and the Flask application sends an email. Outside of using Flask, this setup is identical to the one outlined above. Emails do send, but they are not being signed by Opendkim. Emails sent with a Python script running from the terminal on the same machine that the Flask application is running on are getting signed by Opendkim. So, I know that Postfix and Opendkim are working, it just does not want to sign an email originating from the Flask application.

I cannot figure this out. Flask is running on 127.0.0.0.1:5000. I have also tried running it on 0.0.0.0:5000. I have tried sending post requests using a Python scrip running on the same machine. They all work, in that an email is sent, but i cannot get Opendkim to sign them.

Any help would be appreciated.

0

There are 0 best solutions below