Even more technology hate. I was tasked with forwarding stored emails from a database table. Fine, can't be that hard, right? Well...
The problem is that we occasionally get emails into our ticket system from clients who use emails composed in Outlook, which is a reasonable thing. Outlook however likes to insert lots of nonstandard quoted printable characters into emails, such as the pretty smart quotes. Fine, except apparently PHP's IMAP decoder throws a tantrum upon running into these, resulting in tickets being created that end at mysterious spots.
So as a stop gap I was asked to take the raw email, which is stored, and resend it to an arbitrary email address specified by the user. Fine. Some time later, I discover that there is apparently no way to use PHP's mail functionality, nor PEAR's mail classes to send an email using the raw data.
Instead, I finally stumbled across a code snippet demonstrating how to use socket connections and direct SMTP commands to send the email. Cue an hour trying to figure out how to authenticate to the thing, since I couldn't figure out if the stored user name or password for the mail server were wrong, or if I needed to be doing this over IMAP, or what. Apparently just not authenticating at all was the right answer. Good to know that our servers don't actually check this.
Anyway, the code didn't work. I spent many hours trying to deduce why fgets was hanging when reading responses to the SMTP commands. I couldn't figure it out, and no amount of debugging was being helpful. I could send the first command to the server, but the connection just hung after that. Doing it personally over telnet worked fine!
The problem? I was using \n as a line ending instead of \r\n. The server never realized I was done with the first command and merrily sat there waiting for me to finish. Seriously. Many hours wasted. Because Windows and Linux use different line endings. I even knew about this, but didn't bother to check if the mail server was a Windows server (it is). Or if SMTP requires \r\n instead of just \n (probably). The code snippet I found just used \n, so I figured that was all that was needed.
Oh well, at least I get to write some angry comments in the code. I always enjoy doing that.