0

I am writting a simple backend only i can access but it will have access to other mysql databases of other software, got that working great and the dashboard looks good but the one thing i am getting stuck on is I am trying to display a html table with data from the database and then in one column there will be a button that when clicked launches a window to email the client based on client information retrieved from the mysql table.

Long winded sorry, I have got all the code working bar one thing the form i use posts to a php file called email.php for example and should then send the information via email to the email address provided by the database. i have got myself bogged down here and can't quite seem to get this to work i have tried all sorts of methods but the email does not get sent. below is a snippet of the email.php code:

<?php
if(isset($_POST["submit"])){
    // Checking For Blank Fields..
    if($_POST["email"]==""||$_POST["subject"]==""||$_POST["message"]==""){
        echo "Fill All Fields..";
    }else{
        // Check if the "Sender's Email" input field is filled out
        $email="support@ohostme.com";
        // Sanitize E-mail Address
        $email =filter_var($email, FILTER_SANITIZE_EMAIL);
        // Validate E-mail Address
        $email= filter_var($email, FILTER_VALIDATE_EMAIL);
        if (!$email){
            echo "Invalid Sender's Email";
        }
        else{
            $subject = $_POST['email'];
            $message = $_POST['subject'];
            // Message lines should not exceed 70 characters (PHP rule), so wrap it
            $message = wordwrap($message, 70);
            // Send Mail By PHP Mail Function
            mail($email, $subject, $message, $headers);
            echo "Your mail has been sent successfuly ! Thank you for your feedback";
        }
    }
}
?>

So form would be:

email: the email address of client to be sent email(we get this from database using php echo)

subject: the subject passed by the (value="") option always the same.

message: this is the generic message already created and in the textarea an email pre written (this is sent via $post using the name attr of message to the php script).

Now i have all the code working but the sending function as no email is ever received.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • What OS are you using? – RiggsFolly Feb 14 '16 at 17:43
  • you are doing it on localhost? if yes you need to do bit more stuff:- http://stackoverflow.com/questions/19132171/send-email-from-localhost-running-xammp-in-php-using-gmail-mail-server or http://stackoverflow.com/questions/15965376/how-to-configure-xampp-to-send-mail-from-localhost or http://planetghost.com/send-emails-localhost-xampp-wamp-php or http://sforsuresh.in/sending-email-localhost/ and if you are running this code on live server ask the server provider that mail settings are configured or not. – Alive to die - Anant Feb 14 '16 at 17:44
  • Are you using your localhost for testing an email?If yes then your mail function will not work on your localhost. – Mr. Engineer Feb 14 '16 at 17:44
  • using localhost and testing behind a locked down folder only i have access to. – jonathan76 Feb 15 '16 at 18:14

0 Answers0