I just got php set up on a new server at a hosting company and mail() is not working. I don't get an error message but the mail does not go through. Is there anything that needs to be turned on in php.ini? How can I trouble shoot where the problem is coming from?
mail() not working
This can be a real PITA, because there are so many things that can be standing in the way of discovery.
Are you testing the result of the function call?
$yes=mail("me", "my", "wherever");
if (!$yes) {
echo "Mail failed!";
}
How else are you checking success?
There could be firewalls in the way, your mail could be flagged as spam by the receiving server (look into setting the "From:" line to something that's not likely to be considered an automatic mailer).
Try setting an "Errors-to:" header and see if you get a bounce to your inbox.
If it's an OS specific issue, then check your path to sendmail (if 'Nix) and if Windoze, make sure the proper SMTP host and port are noted in php.ini ...
Many 'Nix servers will run something other than Sendmail, and turn Sendmail OFF; some of these MTA's will alias themselves as sendmail and some may not... that could be it.
HTH,
I get a parse error when I run this.
$yes =mail ("me" ,_ "my" ,_ "wherever" );
if_(! $yes )_{
___echo_ "Mail failed!" ;
}
Also tried this:
$yes =mail ($to ,_ $subject,_$message, $headers);
if_(! $yes )_{
___echo_ "Mail failed!" ;
}
There could be firewalls in the way, your mail could be flagged as spam by the
receiving server (look into setting the "From:" line to something that's not
likely to be considered an automatic mailer).
Tried this.
Try setting an "Errors-to:" header and see if you get a bounce to your inbox.
Tried this. No return.
I'm using a Unix box.
make sure the proper SMTP host and port are noted in php.ini ...
This is all that's in the php.ini file:
doc_root=/usr/share/web/laxworld/webshare
magic_quotes_gpc=1
register_globals=1
Is there a function that will return what my smtp server name is?
Many 'Nix servers will run something other than Sendmail, and turn Sendmail
OFF; some of these MTA's will alias themselves as sendmail and some may
not... that could be it.
How would I check this?
Thanks for all your advice!
- Jon
Response depends on your flavor of nix. But you won't get a response back if it isn't running. At the command line, do a ps -aef|grep sendmail
This is the output from HPUX...
move@hpwms1(1)% ps -aef|grep sendmail
root 1392 1 0 Sep 14 ? 2:59 sendmail: accepting connections on port 25
move 21120 20617 1 16:29:13 ttyue 0:00 grep sendmail
move@hpwms1(2)%
LordShryku,
Using Telnet, I typed in:
ps -aef|grep sendmail
It returned this line:
webshare 1012 973 0 23:34 pts/0 00:00:00 grep sendmail
I have no idea what to do with this information! Hehe. Can you shed some light?
If that's the only thing returned, then sendmail isn't running. That output was the process id created for you running that command.
Ok. So, how can I get mail() running?
Sounds as if you need to do at least 3 things:
Start an MTA on the server.
Put the path to the MTA in php.ini as:
sendmail_path=/path/to/my/mtaRestart the webserver.
I'd think that good ol' sendmail(8) should be available on most Unix or Unix-like systems. You might check your manpages or system documentation to see more exact instructions than these...
I guess another possibility would be to use an external mail host, but to me that's pretty complex --- or at least I've never tried it with PHP
HTH,
The MTA may be the right thing to do. I'm guessing they already have some sort of alternate mail demon running. You may want to do a ps -aef|grep mail to see what comes back from that. If you get the daemon back from that, you can point PHP to it....
Thanks again for your help!
I should mention that everything was fine until the hosting company moved me to a new machine. That's when mail() stopped working.
Might re-installing PHP do the trick?
Excuse my "Newbie-ness" but what's an MTA?
I typed "ps -aef|grep mail" into telnet and got the following back but I have no idea what to do with this info.
qmails 354 352 0 Sep03 ? 00:01:10 qmail-send
qmaill 358 354 0 Sep03 ? 00:00:16 splogger qmail
root 359 354 0 Sep03 ? 00:00:10 qmail-lspawn ./Maildir
qmailr 360 354 0 Sep03 ? 00:00:02 qmail-rspawn
qmailq 367 354 0 Sep03 ? 00:00:06 qmail-clean
root 4999 1 0 Sep29 ? 00:00:00 sleep-svc qmail-smtpd
tcpserver
-x /var/qmail/tcp.cdb -u1001 -g102 -c200 -DRH -lnemesis 0 25
/sbin/smtp-getauth
/usr/local/bin/rblsmtpd -r bl.spamcop.net -r list.dsbl.org /usr/sbin/smtpd
/var/
qmail/auth/vchkpw --smtp
qmaild 5005 4999 0 Sep29 ? 00:00:03 tcpserver -x
/var/qmail/tcp.cdb
-u1001 -g102 -c200 -DRH -lnemesis 0 25 /sbin/smtp-getauth
/usr/local/bin/rblsmtp
d -r bl.spamcop.net -r list.dsbl.org /usr/sbin/smtpd /var/qmail/auth/vchkpw
--sm
tp
root 5006 1 0 Sep29 ? 00:00:00 sleep-svc qmail-pop3d
tcpserver
-c200 -DRH -lnemesis 0 110 /var/qmail/bin/qmail-popup nemesis
/var/qmail/auth/vc
hkpw --pop /sbin/smtp-setauth /var/qmail/bin/qmail-pop3d .
root 5013 5006 0 Sep29 ? 00:00:06 tcpserver -c200 -DRH
-lnemesis 0
110 /var/qmail/bin/qmail-popup nemesis /var/qmail/auth/vchkpw --pop
/sbin/smtp-
setauth /var/qmail/bin/qmail-pop3d .
root 5032 1 0 Sep29 ? 00:00:00 sleep-svc emailAdmin
tcpserver -
DRH -lnemesis 0 1038 /usr/lib/emailAdmin/emailAdmin_server
root 5035 5032 0 Sep29 ? 00:00:00 tcpserver -DRH -lnemesis 0
1038
/usr/lib/emailAdmin/emailAdmin_server
webshare 19725 19629 0 14:45 pts/0 00:00:00 grep mail
OK, so you're on a hosting company? I'd gripe at them a bit
They're using qmail instead of sendmail, so you'll probably need to find the path to the (correct) qmail executable and put that in your php.ini file. However, I caution you, that's just a guess on my part, and so is the following (I'm a traditionalist, use sendmail myself....)
Looks like it might be "qmails". Try this at your telnet prompt:
$whereis qmails
If 'whereis' doesn't work, try also 'locate' and/or 'which'.
One of these should give you a path, likely
/usr/bin/qmails
/usr/local/bin/qmails
/bin/qmails
Try that in your php.ini.
HTH,
So, I want to type
qmail=/usr/share/web/qmail
into the php.ini file
...right?
If that's the right executable, you'd type
sendmail_path=/usr/share/web/qmail
(which seems like a weird path, but, whatever, it's probably Linux, their hier(7) is a tad messed) in your php.ini file, and then restart the websever. Then, calls to the PHP mail() function will attempt to use /usr/share/web/qmail as the MTA (which, BTW, means " Mail Transfer Agent")
I'll cross my fingers for 'ya....
I got it working! Thanks so much for all your help!