Archive for February, 2008

troubleshooting obscure php email issues

Tuesday, February 26th, 2008

One of my current web development/programming projects is being built on a server that I have no access to. It’s quite challenging, to say the least! One of my issues, and the hardest to resolve, was email.

I use the ordinary mail() PHP function. No classes, no cgi, just the function with HTML headers. But it seemed that certain emails I sent from the server were going nowhere, and no failure was being reported either. For example, I could receive mail at my “theconnorswebsite.com” domain, but not my “whitewavedesigns.com” domain.

Well, first I learned that there was no formal MX record, and my server followed that protocol. One was set up on this particular server, but still, I could not receive email at my wwd domain.

I then tried to specify the smtp server, port and from address:

ini_set("smtp","mail.website.com");
ini_set("smtp_port","25");
ini_set("sendmail_from","info@website.com");

That didn’t work either. I also made sure that the server would allow “from” emails to be from any domain by substituting various emails at different domains as the “from”. I even double-checked my HTML headers:

MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1
From: Website <info@website.com>

Then, one of the programmers who works on this mystery server told me that their MTA (mail transfer agent) was Postfix, and a quirky thing about Postfix on a Linux box was that it would not tolerate the “\r” tag when adding additional headers such as “CC” or BCC”. For example, this is how I was writing my headers:

$headers.= "\r\nCC:".$postformAR['Email'];
$headers.= "\r\nBCC:".$postformAR['Webmaster'];

(I put the carriage-return/line feed in front of the cc and bcc so it can be optional.) I had heard that Windows servers don’t especially like the “\r” carriage-return tag, but a Linux server? Well, okay, I removed it.

Then, as if by miracle, some of the emails were coming through! But still not all of them… I finally sat down today and line-by-line tried to figure out why some of my code was working and some wasn’t. Eventually, I got down to the actual mail() function.

Now, according to php.net, this is the mail() function description:

bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

Note the last “additional_parameters”. Sometimes, I use this last parameter “-finfo@website.com” for failed messages, bouncebacks, etc. I don’t tend to use it when someone submits an email to my site, but I do use it when sending out bulk emails like newsletters. As I found out today, for whatever reason, that last parameter was actually required!

So, my fellow programmers, should you ever have email that is sent from your serve simply vanish into cyber-space, I hope this gives you a few more tricks up your sleeve to resolve the issue.

more reasons to reduce beef consumption

Saturday, February 16th, 2008

Today, I read an article in the New York Times, and watched the accompanying video, about sick cows made to stand and/or walk so they could be slaughtered, and then eaten.

About a year ago, I lowered my conventional beef intake to once a week. Now, I have decided that I will only eat naturally-raised beef once a week. I don’t want to be a vegetarian, and I don’t care for fish (even if I did, we hear so much about over-fishing that I wonder if that’s a viable option), so I will continue to eat meat. Beef is (was) the only conventional meat I eat. No more.

The image of the cow just waiting to die reminded me (literally) of the look on Timone (my deceased Italian Greyhound, my poopsie) when he was extremely ill. At that point, we knew we had no alternative than to put him down. How sad (that’s an understatement) that people could see that cow and not be moved.

What is with the USDA that they could allow this? Honestly, we’re talking about food that millions of people, including children, eat! Do they eat this stuff? Do they feed it to their children? I am appalled enough about the notion of not labeling genetically modified foods or even meat that may be from cloned animals*, but to allow us to each sick animals is horrendous. At least they closed down this plant. I wish we could close down the USDA! Well, maybe not, but at least get it to do the job it’s supposed to do.

*To the best of my knowledge, cloned meat is not (yet) used for human consumption. I don’t know if I’d want to eat cloned meat, but sure as hell know I’d want to make that choice myself!