First thing I'd do is check your apache/IIS logs to ensure that the URL isn't being called twice (just a sanity check).
If the PHP page you've added to your OP is http://mysiteurl/addtext.php
, then it would be called twice, once renderering the HTML, then the browser would call it again when rendering the <img ...>
tag.
To fix this you need to either split it into two PHP files (recommended), or pass a GET parameter to toggle the image processing.
You'll also need to add $headers .= "Content-type: text/html\r\n";
so that the email is rendered as html and not plain text.