Portal Home > Knowledgebase > Articles Database > php mail() not working on new server


php mail() not working on new server




Posted by mjfroggy, 09-03-2009, 09:56 AM
Hello all, So I just setup a ubuntu LAMP server. Now I have reports that php mail() is not working?? when I look at my phpinfo() I see sendmail_from no value no value sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i yet I have even tested it out and see that my script says it works but the mail never reaches my inbox?? Suggestions on what I might have missed during the setup or maybe there is a config I need to change in my servers php.ini file ?? here is my php script

Posted by eth10, 09-03-2009, 11:15 AM
pear install mail Use this command

Posted by odishahost, 09-03-2009, 11:51 AM
please paste the error from the logs here; is there a problem in sending emails using webmail or email client ?

Posted by SPaReK, 09-03-2009, 12:33 PM
First, make sure that /usr/sbin/sendmail really exists on your server. If it does, you will need to tail the mail logs while attempting to execute this PHP script. See what the mail logs say about this.

Posted by mjfroggy, 09-03-2009, 12:42 PM
Hello eth10 I have PEAR mail installed although it is not working and I really am just looking to get the php mail() function to work. Not SMTP based email. Also I dont have cpanel or any other panel installed Its just a basic Ubuntu LAMP install which will mostly be used by a client who is a developing a large scale PHP App. I am not sure what log file to look at I have a var/log/mail.log but its empty and I dont see any php related log's??

Posted by SPaReK, 09-03-2009, 12:55 PM
If sendmail is your MTA then I believe /var/log/mail.log will be the log to look at. Is sendmail running? /etc/init.d/sendmail status to restart it: /etc/init.d/sendmail restart Are you able to send out e-mail from the server bypassing PHP?

Posted by mjfroggy, 09-03-2009, 01:09 PM
Yes Sendmail is running I get MSP: is run via cron (20m) MTA: 6895 /usr/sbin/sendmail-mta -Am -L sm-mta -bd -q10m UID PID PPID C STIME TTY TIME CMD root 6895 1 0 12:57 ? 00:00:00 sendmail: MTA: accepting connections Daemon Status: (process 6895) Accepting connections Current number of children: 0 QueueDir free disk space (in blocks): 14553136 Load average: 0 Child Process 6945 Status: console socket child QUE: Same as MTA

Posted by SPaReK, 09-03-2009, 01:29 PM
Try sending a message out directly through sendmail. Create a test file, doesn't really matter what you name it, but I'll call it test.txt for reference purposes. In that file add the lines: save that file and then from the command-line type: /usr/sbin/sendmail -t -i < test.txt You should receive a test message at someother@address.com and your mail.log file should have entries.

Posted by fabin, 09-03-2009, 02:16 PM
what does you apache error log say?

Posted by mjfroggy, 09-03-2009, 02:27 PM
well my var/log/apache2/error.log has nothing about email in it just some missing image errors and I dont see any error log just called apache2.log ?? I only see access.log and error.log in the apache2 log folder

Posted by fabin, 09-03-2009, 02:34 PM
When you run the mail() in php file, what does your mail log say?

Posted by mjfroggy, 09-03-2009, 03:11 PM
mail.info log says My mail.log file says the same as above mail.warn log is empty and mail.err is empty as well I also even tried setting up and using pear Mail and get this error Warning: Mail_smtp::include_once(Net/SMTP.php) [mail-smtp.include-once]: failed to open stream: No such file or directory in /var/www/PEAR/Mail/smtp.php on line 311 Warning: Mail_smtp::include_once() [function.include]: Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/var/www/PEAR/') in /var/www/PEAR/Mail/smtp.php on line 311 Fatal error: Class 'Net_SMTP' not found in /var/www/PEAR/Mail/smtp.php on line 312 yes I have a REAP folder and a Mail folder in it and I see there is a smtp.php file in the Mail folder. with the correct upper and lowercase letters Last edited by mjfroggy; 09-03-2009 at 03:13 PM. Reason: more info



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
CHMOD 755 or 777 (Views: 659)