12

I've been struggling to get a really basic PHP function working on my iMac, the PHP mail() function.

I've used it countless times, albeit on a Windows platform and now I'm trying to get it running on Mac.

I've installed XAMPP v1.01 maybe because I didn't know any better at the time and I thought it would all just work fine, because that's what it's supposed to do. (Or so I thought).

I've tried the following pages of instructions to no avail:

To start with I did not have an entry for: MAILSERVER=-YES- in my /etc/hostconfig so I created it.

I added the full path to sendmail in my php.ini: sendmail_path = "/usr/sbin/sendmail -t -i"

I understand I don't need to set a myhostname variable in /etc/postfix/main.cf because I'm only planning on sending mail not receiving it. (NB. I've also tried it with this setting enabled!)

I've start postfix and then tried running the script but the script just processes with no error message, it just basically constantly looks as if it's working but nothing happens (I've triple checked the code for script).

I noticed some peoples solutions do not even mention having to start the postfix daemon for them to get the PHP mail() function to work.

Any ideas or things for me to try?

If you need more info, please ask.

P.

Yes Barry
  • 9,514
  • 5
  • 50
  • 69
paperclip
  • 2,280
  • 6
  • 28
  • 39
  • 1
    Have you looked at the log files for sendmail? What errors are you receiving? – thetaiko Mar 15 '10 at 21:42
  • Where can I grab the log files from? I've tried: tail -f /var/log/mail.log after starting postfix but I don't see anything helpful there just a constant stream of entries even when postfix has been stopped. – paperclip Mar 15 '10 at 21:48
  • Thats probably the file you want - are there any errors specified in there? Invalid domains, sender verification failures, etc? – thetaiko Mar 15 '10 at 21:51
  • A sample: Mar 15 21:05:24 imac postfix/postdrop[1651]: warning: mail_queue_enter: create file maildrop/900320.1651: Permission denied Mar 15 21:05:34 imac postfix/postdrop[1651]: warning: mail_queue_enter: create file maildrop/900657.1651: Permission denied Mar 15 21:05:44 imac postfix/postdrop[1651]: warning: mail_queue_enter: create file maildrop/901029.1651: Permission denied Mar 15 21:05:54 imac postfix/postdrop[1651]: warning: mail_queue_enter: create file maildrop/901346.1651: Permission denied They are all similar. – paperclip Mar 15 '10 at 22:06
  • 1
    Try opening Disk Utility and running repair permissions. The problem is clearly a permissions error. – thetaiko Mar 15 '10 at 22:15
  • The repair permissions did the trick and PHP scripts are completing but mail only gets as far as the mail queue and doesn't send. I can see it sitting in mailq, and I can't flush with sendmail -q or postqueue -f. Any ideas? – paperclip Mar 16 '10 at 22:32
  • You don't need to use xampp, OS X comes with a fully configured PHP. – Mahmoud Al-Qudsi May 06 '12 at 20:22

2 Answers2

1

XAMPP uses its own /etc folder, it is contained within the applications bundle. You right click and select show package contents. Now follow the guides you have listed but apply the changes to this /etc folder not the macs /etc folder.

0

Pasting in an answer from here: http://macosx.com/forums/unix-x11/19819-sendmail-not-working.html

Sounds like your problem based on the log entries you posted.

Additionally, the author of that post recommends that you'll have to do this again after a system update, so "repair permissions" is NOT what you want....and possibly the OPPOSITE of what you want.

The most common problem with sendmail on OS X is just a permission problem, and one which will show up after installing most packages from Software Update. Check /var/log/mail.log and see if it's complaining a lot about a group writable directory. If that's the case, then the problem is that the root directory is group writable. That's easily fixed with a quick "sudo chmod g-x /". Then sendmail should be able to start properly, and I think it can be invoked by typing "/usr/sbin/sendmail -bd -q1h". Again, if all else fails, reboot.

audiodude
  • 1,865
  • 16
  • 22