Archive for April, 2007

using php mail() with postfix

Monday, April 16th, 2007

First, let me give a short history… I had to make a script at work that would get fired off by our hylafax server when ever an incoming fax was recieved. This script needed to check the caller id info and see what number was dialed, then based on that either move the file into a dir for the department it was intended for, or if it was ment for a person then to convert the tiff file into a pdf then email them the fax. Sounds simple enough… So for what ever reason my boss is hung up on using php for everything so I start working on this thing in php. We are using asterisk at work with IAXmodem to make asterisk and hylafax work happy like.. We have given all 90+ users we have their own DID as well as their own FaxDID. What I do with this script is lookup the number that was passed with callerid info in a mysql database to see whos umber it is, I get their username and their email as well as some other info, then mail the user the fax. I decided to use Pear for this because I like to reuse code when ever possible. I made a simple script to get the job done and damn to hell if it wouldnt work. I would get an email with the headers all screwed up. I knew they were not getting messed up in the php because I could print the email (headers and all) to the command line and it was perfect. I tried this same script on another box (that happened to have sendmail) and it woked perfect. I spent all damn day trying to figure out why my emails were not being sent correctly today. Then along came my good buddy Caleb. The first words from his mouth were ” I bet the working servers are sendmail and the nonworking are postfix” Sure enough that was the case. For what ever reason postfix is adding 2 new lines to my stuff. The fix was really extremely trivial.

$body = $mime->get();
$body = str_replace(“\r”,”,$body);
$headers = $mime->headers($headers);
$headers = str_replace(“\r”,”,$headers);

The full script can be found here. This script is not the best work ever, and it could be improved for sure. But this is what I am using. I hope someone can find it useful someday.

Double Damn!!

Wednesday, April 11th, 2007

Well my car needs a new mass air sensor, and a tune up. $600 later Ill be able to pick it up.. What a flippin rip off man.. Oh well. If I had my tools here and a couple hours to spare on Saturday, and a place to do the work (no auto repairs allowed at the apartments I live in) I would do it my self for under $200 bucks.


Monday, April 9th, 2007

So my car has been running kinda rough for a while now and the stupid “Check Engine” light has been on since the day I bought the car. I decided that I should get it fixed before the summer time gets here and the stupid car breaks down on the freeway and leaves me stranded.Now with my new fancy job I dont really have time to screw around with fixing my car my self, and all my tools are still in Odessa because I dont have any where to store the tool boxes. I take the car to a local shop today that was right down the street from my house. Its basicly 1/2 way to my office. I know from having wokred in a shop for most of my working life that getting a car fixed isnt cheap. Infact it can be damn expensive. I told the service writter the symptoms my car had and he told me it would be Wednesday at the earliest before they could look at it. Thats no problem for me since the car does still run it just runs kinda crappy. I set up the apointment and tell them I will be back Wednesday morning on my way to work. He tells me ok and informs me of their service chanrge to “check out” my car. Brace your self folks because I nearly passed out smooth. They have a 1 hour charge to check out the car… at a whopping $84.50. I was like holy shit!! I can recall going to a new doctor for the first time about 18 months ago and not havving health insurance and only paying $90 for the office visit. I mean shit.. the doctor went to college for what.. like 10 years or more, and I pay him $90 and I have to pay some guy who at best has a 2 year degree and most likely just took some test to get a cert like the ASE. Did I give up the being a mechanic at the wrong time.. Our shop charged $57.10 an hour and I thought we were a little on the high end.. but wow these folks may be charging more than the dealer.. I will have to look into it and find out. I do still plan on taking them my car becuase I dont really have time to go out looking for a better deal either, and with me not really having anyone here who can take me around or anything Im just gonna have to spend the money this time.. Ill keep you posted on what ends up being wrong.