MortimerJazz Posted January 13, 2007 Share Posted January 13, 2007 Hi there,I'm kind of new to the world of setting up dedicated servers so would appreciate some advice on how to set up the mail () function in my PHP.ini on a Linux server.Is there a generic path that I need to use in order to allow the mail function to work in the scripts?We do have a mail server set up, the address of which being "mail.companyname.com" ... do I need to insert that into the ini file somwhere instead?Any help would be REALLY appreciated.Thanks, Quote Link to comment Share on other sites More sharing options...
trq Posted January 14, 2007 Share Posted January 14, 2007 Is your mail server on the same machine?All you need do is setup an smtp daemon. Id'e recommend ssmtp as its real simple to configure. Im not sure what distro your using so I wont go into details but, install ssmtp, then open the configuration file (should be /etc/ssmtp/ssmtp.conf or simular) and view the examples.ssmpt will set itself up as a replacement for sendmail (sendmail is alot more difficult to configure), ie it will create soft links making it look like sendmail. Then you away.Hope this helps. Quote Link to comment Share on other sites More sharing options...
MortimerJazz Posted January 14, 2007 Author Share Posted January 14, 2007 Thanks loads for the reply[quote]Is your mail server on the same machine?[/quote]The mail server I mentioned above is on a different machine. The dedicated server we're renting is only accesible by remote access. Am I right in assuming that the dedicated server won't send mail without the mail server?At the moment, sendmail_path in the php.ini is set to [b]/usr/sbin/sendmail -t -i[/b], which seems to be the default suggested in various articles I've read on Google but it's still not working. Quote Link to comment Share on other sites More sharing options...
trq Posted January 14, 2007 Share Posted January 14, 2007 Either way (local mailserver or not), you need to setup an smtp daemon as Ive suggested. Once that is setup you should be good to go. Quote Link to comment Share on other sites More sharing options...
the_oliver Posted February 4, 2007 Share Posted February 4, 2007 You can specify a diffrent mail/smtp server to use in the php script, although i forget how to do it. All you need to do in the ini script make the standard mail() comand is enabled. (by default it is).As thorpe said though it is simpler just to set up a basic smtp server on the host. Is very important though to ensure that the local smtp server only allows localhost connections, else you may find your self blacklisted, (allowing to much spam relaying etc). Quote Link to comment Share on other sites More sharing options...
newladder Posted May 19, 2007 Share Posted May 19, 2007 Hello Friends,Iam very new to LAMP installtion,I have congifured the sendmail and tested using cmd and it is sending the mail but when i send the mail from php with simple mail() funcion it is not sending any mail but it says mail sent.Can anyone please help me out in this. ?Warm Regards Quote Link to comment Share on other sites More sharing options...
the_oliver Posted May 19, 2007 Share Posted May 19, 2007 Where does it say mail sent?Can you post part of your sendmail log showing an attempt to send? Or does it not appear in your send mail log? The log will have the definitive word! Quote Link to comment Share on other sites More sharing options...
newladder Posted May 19, 2007 Share Posted May 19, 2007 Hi Oliver,Thanks for the quick reply,Since iam new to this stuff i have no idea where is the log get stroed. Can you please tell me where I can find the mail log ? Quote Link to comment Share on other sites More sharing options...
newladder Posted May 19, 2007 Share Posted May 19, 2007 Here is my php code<?phperror_reporting(E_ALL);mail("visit2imran@gmail.com","Subject","Content");if (mail){ echo "mail sent...";}else{ echo "unable to send mail";}?> Quote Link to comment Share on other sites More sharing options...
the_oliver Posted May 21, 2007 Share Posted May 21, 2007 Firstly a friendly word of advice: Dont post your real email address in forums like this! You may want to eddit it out of your preious post. Sort of thing that spamers scan for, and before you know it your bombarded with gunk! . . . . . Try this small change and see if it makes any diffrence:[code]$success = mail("youremail@domain.com","Subject","Content");if ($success){ echo "mail sent...";}else{ echo "unable to send mail";}[/code]The above will however not tell you that the message has been sent, just that it has been sent to the server so you have to look a little deeper ie the logs.If your using sendmail (the 'out of the box' standard) unable to diliver problems are offten sent strait to your root mail box. From the comand line, login as root and type: "mail". If its set up you should get a list of messages appear. The hit enter and have a read. to exit just hit "q" twice then enter again. Could be a usefull diagnosting!Failing that try (again as root) [quote]ps axvw | grep sendmail[/quote]and post us the outputShout if none of that made sence! Oh . . . and can you tell us what linux you are using.Engoy! Quote Link to comment Share on other sites More sharing options...
newladder Posted May 22, 2007 Share Posted May 22, 2007 Hello Oliver,I have tried with your code and also typed the following command on cmd "ps axvw | grep sendmail" and found the below output[root@Mstore ~]# ps axvw | grep sendmail 5143 ? Ss 0:00 0 704 8252 2224 0.3 sendmail: accepting connections 5151 ? Ss 0:00 0 704 7172 1636 0.2 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue 6881 pts/2 S+ 0:00 0 71 4532 644 0.0 grep sendmailRegards Quote Link to comment Share on other sites More sharing options...
the_oliver Posted May 22, 2007 Share Posted May 22, 2007 Ok, so that shows that Sendmail is setup and running. Next thing to do would be to look in the logs. They should be in /var/log/ and called something like mailog. Have a look in this and see what it shows. Will say wheter it tried to deliver, did deliver, or if the messages are not in there then its not getting them! Quote Link to comment Share on other sites More sharing options...
solarisuser Posted August 17, 2007 Share Posted August 17, 2007 1) Log onto the machine's terminal, and run 'tail -f /var/log/maillog'2) Run the PHP script3) Look for errors from tail. If you do not see errors, look at the PHP error_log file, defined in /etc/php.ini4) Look at http://www.php.net , and type in 'mail' on the top right of the page to find examples of proven ways to use mail() Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.