I\'m trying to create a fake email server as part of a Flask app to print out errors on the console by using the following script. However, it throws an error. How can I fix
If you are doing this as an exercise, then @solarnz has the right approach. If however, you need this done for work there is a far better solution in mailcatcher:
MailCatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface. Run mailcatcher, set your favourite app to deliver to
smtp://127.0.0.1:1025
instead of your default SMTP server, then check outhttp://127.0.0.1:1080
to see the mail that's arrived so far.
This is a program designed especially for developers whose apps need a mail server for testing but they don't want to set one up.
The great bonus is that it comes with a web interface to view messages sent by your application: