The Daily WTF
Follow
CodeSOD: Don't Read This Email
The code in question handles sending an email containing HTML. It opens with a check for 'action' and 'send' parameters in the GET request. If present, it proceeds to assemble the email.An HTML template is retrieved, and its placeholders are populated with form data and database query results. The resulting HTML is then used to create the email body.Three tables are generated, each containing product data and links. These tables are inserted into the HTML template using a simple templating engine.If the 'preview' parameter is set, the email is sent to a preview address. Otherwise, it is sent to a list of customers who have opted for special offers.The code demonstrates poor coding practices, including repeated find-and-replace operations and inefficient variable handling. Despite being expensive and experienced, the developers appear to have invested unnecessary effort in the implementation.The code concludes with the generation of a header and the inclusion of various files for styling and functionality.