Sendmail not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpnewbieperson
Forum Newbie
Posts: 22
Joined: Wed Mar 26, 2008 8:25 am

Sendmail not working

Post by phpnewbieperson »

Hi,

I have a simple php script that uses the mail function, and all seems to work, but the email it sends never turns up. I've search stacks of sites, but I can't seem to find anything that works. The server is running php5 and phpsuexec. My script is:

Code: Select all

<?php
            if (isset($_GET['do'])) {
            $sign_up_button = false;
            $task = $_GET['do'];
            switch ($task) {
                case "send" :   echo "<p class=sent>Thanks for your enquiry, it has been emailed to us. We will respond as soon as possible.</p>";
                                //start building the mail string
                                $msg = "Name:  $_POST[name]\r\n";
                                $msg .= "Email:  $_POST[email]\r\n";
                                $msg .= "Phone: $_POST[phone]\r\n";
                                $msg .= "Message:  $_POST[message]\r\n";
                                //set up the mail
                                $recipient = "emailaddress@goeshere"; //obviously this has been changed
                                $subject = "** $_POST[subject] **";
                                $mailheaders = "From: $_POST[name] <$_POST[email]>\r\n";
                                $mailheaders .= "Reply-To: $_POST[email]\r\n";
                                $mailheaders .= "MIME-Version: 1.0\r\n";
                                //send the mail
                                mail($recipient, $subject, $msg, $mailheaders);
                                break;
                default     :   //do nothing
                                break;
                            }
            }
            else {
            //do nothing
            }
        ?>
drfeelgood
Forum Newbie
Posts: 15
Joined: Mon Sep 01, 2008 9:57 pm

Re: Sendmail not working

Post by drfeelgood »

Have you check sendmail service ?

usually :
/etc/init.d/sendmail start
phpnewbieperson
Forum Newbie
Posts: 22
Joined: Wed Mar 26, 2008 8:25 am

Re: Sendmail not working

Post by phpnewbieperson »

I forgot to mention the domain's mail server is not local. A simple config entry and all works fine now.
Post Reply