I'm not sure how many people will have this problem, but I did so this will remind me.
PHP 5.3 release, for some reason, does not like my default install of iconv. Firstly, I made the grave mistake of failing to point PHP properly at an install in /usr/local/, so replaced my OS installation of iconv with a new one. This was all well and good until I started opening apps that needed specific parts of OSX's default iconv. So, an OSX restore later, we're at square one. PHP keeps telling me various crap when I'm trying to compile that it didn't work with iconv because it's the wrong version, but would fail during make because it couldn't find the correct symbols. <!--more--> I had compiled and installed iconv (./configure --prefix=/usr/local/iconv --enable-static) then pointed PHP at that (--with-iconv=/usr/local/iconv) and it was failing during make with Undefined Symbols: "_libiconv" then some stack trace of php string functions. Great. After much Googling and cobbling together my own way to do this with trial and error and a mixture of other people's part-baked solutions, I have come up with the following method:
configure PHP with the following prefix: env LIBS="-lresolv -liconv" ./configure ......
env LIBS="-lresolv -liconv" ./configure \ --enable-pdo \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql=/usr/local/mysql \ --with-pdo-mysql=/usr/local/mysql \ --prefix=/usr/local/php \ --enable-mbstring \ --with-mysql=/usr/local/mysql \ --enable-cli \ --with-curl \ --with-gd \ --with-png-dir=/usr/local/png \ --with-jpeg-dir=/usr/local/jpg \ --with-freetype-dir=/usr/local/freetype \ --with-zlib-dir=/usr/local/zlib \ --with-mcrypt=/usr/local/mcrypt \ --with-iconv=/usr/local/iconv
After configure has finished running, hopefully there has been no problem. If there has I have no idea how to fix it. Normally this runs smooth as hell for me, this has taken me about 6 solid hours to fix and I can't be remotely fixing everyone else's, sorry.
You'll need to be modifying the Makefile generated from your ./configure. Search for the following string (without quotes) "libs/libphp$" and replace that and the next line with the following:
libs/libphp$(PHP_MAJOR_VERSION).bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(CC) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) $(MH_BUNDLE_FLAGS) -o [email protected] && cp [email protected] libs/libphp$(PHP_MAJOR_VERSION).so
Again, I must reiterate, if this doesn't work for you I probably won't be able to fix this or even help you slightly. This is just what worked for me. There are plenty of things you can try with a bit of Google-fu, though.
So I couldn't figure out any way of doing this, and I can't stand stuff like this beating me so I've been messing about with it for the last hour and it's finally working so I thought I'd share what I've done. Maybe this will get spidered, but mostly it'll be here for my future reference!
The long and short of this situation is that OSX includes sendmail, but it seems to be some sort of alias for postfix, so you should actually be configuring postfix. Right now, I should probably clear up that I'm by no means an expert on any of this and it's all been trial and error for me so far so if it doesn't work for you, I can try and help but I can't promise anything.<!--more-->
There are 4 files I used for the following:
MAILSERVER=-YES-then sudo nano -w /etc/postfix/main.cf, find the myhostname variable (by default it's host.domain.tld), uncomment it and change it to your domain (if you're on a machine that doesn't have a DNS, you can make it a domain that you're responsible for so that it doesn't get shut down at the receiving end, but please don't make it google.com or something like that!)
now, open php.ini and look for the sendmail_path variable, uncomment it, make its value sendmail -t -i, save then restart apache. I'm not really sure if this is 100% necessary as there's a comment above that says this is the default value anyway, but it can't hurt!
now open a terminal window and execute the next couple of commands:
% sudo postfix start % tail -f /var/log/mail.logfinally, create a file called mail.php (or whatever!) and add the following to it:
<?php mail( '[email protected]', // your email address 'Test', // email subject 'This is an email', // email body "From: Me <[email protected]>rn" // additional headers ); ?>obviously replace [email protected] with your email address and [email protected] with a valid email address (domain at least, as some mail servers will bounce your email if the sender's domain isn't real). Now navigate to your mail.php file (likely http://localhost/mail.php) and watch your terminal window to see that it's been sent successfully. If it hasn't, let me know if you fixed it and I'll update this - it's annoying to me that there isn't really an answer to this question that I can find so the more comprehensive this is, the more helpful!.
Useful bit, added by Terry Thorne in the comments:
I just thought I’d add for those looking to do this who find that their ISP blocks port 25 you have to route through their server. On Snow Leopard edit /etc/postfix/master.cf and add at the end: mydomain = yourisp.net myorigin = $mydomain relayhost = mail.yourisp.net Obviously replacing yourisp.net with the domain of your ISP (usually the suffix of your email address) and the mail.yourisp.net with your ISP’s smtp server addresss Taken from: http://www.mail-abuse.com/an_rteoutgoing.html