I have another send email program that I am trying to fix. It's different from the previous one:


<form action="contact.php" name="contactform" class="row" method="post">

                                    <h4>Request a FREE TRIAL CLASS!</h4>

                                    <div id="input_name" class="col-md-12">
                                        <input id="name" class="form-control" type="text" name="stu_fname" placeholder="Full Name"> 

                                    <div id="input_email" class="col-md-12">
                                        <input id="email" class="form-control" type="text" name="stu_email" placeholder="Enter your email"> 

                                    <div id="input_phone" class="col-md-12">
                                        <input id="phone" class="form-control" type="text" name="stu_telp" placeholder="Phone Number"> 

                                    <p>We will respond to you within 24 hours, during regular business hours. All fields are required</p>

                                    <!-- Submit Button -->
                                    <div id="form_register_btn" class="text-center">

                                    <input class="btn btn-theme" type="submit" name="request" value="Request Quotation" id="submit">


                                </form>  <!-- End Register Form -->



$stu_fname = isset($_POST['stu_fname']) ? $_POST['stu_fname'] : '';
$stu_email = isset($_POST['stu_email']) ? $_POST['stu_email'] : '';
$stu_telp = isset($_POST['stu_telp']) ? $_POST['stu_telp'] : '';


            if (isset($_POST['register'])){

            if(!empty($stu_fname) && !empty($stu_email) && !empty($stu_telp)){

            $sqlstr = "INSERT INTO student(stu_fname, stu_email, stu_telp) VALUES('".$stu_fname."','".$stu_email."','".$stu_telp."')";

            $result = mysql_query($sqlstr) or die(mysql_error());

            $result2 = mysql_query("SELECT student_id FROM student ORDER BY student_id DESC");

            $dataSID = mysql_fetch_array($result2);

            $error = "<i>Please fill-in all fields information in this form.</i><br>";

            $result = "";

            //Jika mode edit, maka tidak akan dikirimkan konfirmasi kepada subscriber
            //if (empty($_REQUEST['id']))   kirimEmail($idKategori, $judul, $news);
            $confirmation = ($result) ? "Data has been saved." : "Fail to save data.";  


// PHP Mailer 

require 'C:/xampp/htdocs/phpmailer/PHPMailerAutoload.php';
 //memanggil library php mailernya

function smtpmailer($to, $from, $from_name, $subject, $body) {

global $error;

$mail = new PHPMailer();

//$mail->AuthType = 'NTLM';


//$mail->SMTPDebug = 0;  // untuk memunculkan pesan error /debug di layar

$mail->SMTPAuth = true;  // authentifikasi smtp enable atau disable

$mail->SMTPSecure = "";//‘ssl atau di kosongkas jika none’; // secure transfer membutuhkan authentifikasi dari mail server

$mail->Host ='ssl://smtp.gmail.com:465;tls://smtp.gmail.com:587'; // masukkan nama host email “diawal ssl://”

$mail->Port = 587; //port secure ssl email

$mail->Username = "squprime@gmail.com"; //username email

$mail->Password = "123456"; //password email

$mail->SetFrom($from, $from_name);

$mail->Subject = $subject;

$mail->Body = $body;


if(!$mail->Send()) {

$error = "Mail error: ".$mail->ErrorInfo;

return false;

} else {

$error = "Message sent!";

return true;



    $result = mysql_query("SELECT * FROM student ORDER BY student_id DESC") or die(mysql_error());
    $data = mysql_fetch_array($result);

// write program to send email to the recorded email address

    $name = $data['stu_fname'];
    $email = $data['stu_email'];
    $phone = $data['stu_telp'];
    $message = "Dear Admin,"."\r\r".
    "There is a new user registration";

    /*if (@$_POST['submit']) {*/
    if ($name&&$email&&$phone&&$message) {
    if (is_numeric($phone)) {

    $body = "
    Name: ".$name."
    Phone: ".$phone."
    Email: ".$email."\n\n

    //mail("squprime@gmail.com", "squprime@gmail.com", "Davy", "Request Trial", $body); 

    smtpmailer("squprime@gmail.com", "squprime@gmail.com", "Davy", "Request Trial", $body); 
    //smtpmailer("squprime@indonusa.net.id", "squprime@indonusa.net.id", "Davy", "Test Email", $body); // script kirim email

    echo "Your message has been sent, we will get back to your shortly.";
    $name = trim("");
    $email = trim("");
    $phone = trim("");
    $message = trim("");
    echo "There should only be numbers in your phone number.";
    echo "Please fill in <b>all</b> the fields!";


        <div id="contentForm">

            header('Content-Type: text/html; charset=utf-8');

            if(isset($_POST['email'])) {


                //$email_to = "cs@squprime.com";
                $email_to = "squprime@gmail.com";

                $email_subject = "SquPrime Free trial request!";

                $first_name = $_POST['first_name']; // required 
                $email_from = $_POST['email']; // required
                $phone = $_POST['phone']; // required

                $email_message = "Form details below.\n\n";

                function clean_string($string) {
                    $bad = array("content-type","bcc:","to:","cc:","href");
                    return str_replace($bad,"",$string);

                $email_message .= "Name: ".clean_string($first_name)."\n";
                $email_message .= "Email Address: ".clean_string($email_from)."\n";
                $email_message .= "Phone Number: ".clean_string($phone)."\n";

                // create email headers

                $headers = 'From: '.$email_from."\r\n".

                'Reply-To: '.$email_from."\r\n" .

                'X-Mailer: PHP/' . phpversion();

                //@mail($email_to, $email_subject, $email_message, $headers);

                //$ok = @mail($email_to, $email_subject, $email_message, $headers);

                $ok = mail("squprime@gmail.com", "Subject", "This is the email message", "From me");

                if($ok){ echo "successfully sent message"; } else { echo "failed to send message"; }

                <!-- Message sent! (change the text below as you wish)-->
                <div class="container">
                    <div class="row">
                        <div class="col-sm-6 col-sm-offset-3">
                            <div id="form_response" class="text-center">
                                <img class="img-responsive" src="img/thumbs/mail_sent.png" alt="image" />
                                <h1>Your request is sent!</h1>
                                <p>Thank you <b><?=$first_name;?></b>, our advisor will contact you within 24 hours!</p>
                                <a class="btn btn-theme btn-lg" href="index.php">Back To The Site</a>
                 <!--End Message Sent-->

After I fill-in the information, I receive this message:

Your message has been sent, we will get back to your shortly.

But I do not see the email in my inbox.

Recommended Answers

All 3 Replies

should it be :
$mail->Port = 465; //port secure ssl email

This time I retry again:

Warning: require(C:/xampp/htdocs/phpmailer/PHPMailerAutoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\SquprimeRevise\contact.php on line 75

Fatal error: require(): Failed opening required 'C:/xampp/htdocs/phpmailer/PHPMailerAutoload.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\SquprimeRevise\contact.php on line 75

// PHP Mailer 

require 'C:/xampp/htdocs/phpmailer/PHPMailerAutoload.php';
 //memanggil library php mailernya


I already check the file is there I wonder why the error stilla ppears.

You shouldn't require absolute paths pointing to a C drive. Use a relative path instead.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.