-1
<?php

    $to = "testthetester55@gmail.com";
    $from = $_REQUEST['email1'];
    $name = $_REQUEST['name1'];
    $subject = [$_REQUEST['subject']];
    $email = $_REQUEST['email1'];
    $number = $_REQUEST['phoneNumber1'];
    $business = $_REQUEST['bname1'];
    $pb = $_REQUEST['pb'];
    $Category=$_REQUEST['cat'];
   
    
    echo $name,$pb,$email,$Category,$from,$to,$number,$business;

    $headers = "From: $from";
    $headers = "From: " . $from . "\r\n";
    $headers .= "Reply-To: ". $from . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

    $subject = "You have a new submission from Tea Expo for Sponsor.";

    $logo = 'assets/img/logo/logo.png';
    $link = '#';

    $body = "<!DOCTYPE html><html lang='en'><head><meta charset='UTF-8'><title>Express Mail</title></head><body>";
    $body .= "<table style='width: 100%;'>";
    $body .= "<thead style='text-align: center;'><tr><td style='border:none;' colspan='2'>";
    $body .= "<a href='{#}'><img src='{$logo}' alt=''></a><br><br>";
    $body .= "</td></tr></thead><tbody><tr>";
    $body .= "<td style='border:none;'><strong>Name:</strong> {$name}</td>";
    $body .= "<td style='border:none;'><strong>Email:</strong> {$from}</td>";
    $body .= "</tr>";
    $body .= "<tr><td style='border:none;'><strong>Phone Number:</strong> {$number}</td></tr>";
    $body .= "<tr><td style='border:none;'><strong>Email:</strong> {$email}</td></tr>";
    $body .= "<tr><td style='border:none;'><strong>Business Name:</strong> {$business}</td></tr>";
    $body .= "<tr><td style='border:none;'><strong>Category:</strong> {$Category}</td></tr>";
    $body .= "<tr><td style='border:none;'><strong>Place of Business:</strong> {$pb}</td></tr>";

    $body .= "</tbody></table>";
    $body .= "</body></html>";

   $send = mail($to, $subject, $body, $headers);


   error_reporting(-1);
   ini_set('display_errors', 'On');
   set_error_handler("var_dump");
    
   if($send){   
    echo "sent";

}
else{
     echo "not sent";
}

?>

This is my php email code. It successfully echo all the variables but in the end says not sent due to my if condition. How do i echo the error and if anyone can see whats wrong?.

I have also previously received emails from php on my gmail so i suppose gmail settings is not the issue.

Also adding the form code:

                        <div class="col-sm-6">
                            <label>Full Name</label>
                            <div class="form-group">
                                <input class="form-control valid" name="name1" id="name1" type="text"
                                    onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter your name'"
                                    placeholder="Enter your name">
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <label>E-Mail</label>
                            <div class="form-group">
                                <input class="form-control valid" name="email1" id="email1" type="email"
                                    onfocus="this.placeholder = ''"
                                    onblur="this.placeholder = 'Enter email address'" placeholder="Email">
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <label>Phone Number</label>
                            <div class="form-group">
                                <input class="form-control" name="phoneNumber1" id="phoneNumber1" type="number"
                                    onfocus="this.placeholder = ''"
                                    onblur="this.placeholder = 'Enter Your Mobile No'"
                                    placeholder="Enter Your Mobile No">
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <label>Business Name</label>
                            <div class="form-group">
                                <input class="form-control valid" name="bname1" id="bname1" type="text"
                                    onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter your Business name'"
                                    placeholder="Enter your Business name">
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <label>Category</label>
                            <div class="form-group">
                               <select name="cat" id="cat">
                                   <option value="Sponsor">Sponsor</option>
                                   <option value="Participant">Participant</option>
                               </select>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <label>Place of Business</label>
                            <div class="form-group">
                                <input class="form-control valid" name="pb" id="pb" type="text"
                                    onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter your Place of Business'"
                                    placeholder="Enter your Place of Business">
                            </div>
                        </div>
                    </div>
                    <div class="form-group mt-3">
                    <button type="submit" class="btn btrn-primary" value="Submit">Submit</button>
                    </div>
                </form>
DarkBee
  • 15,492
  • 5
  • 46
  • 56
  • I have also checked the error log on hostinger and its empty – Test the tester May 20 '22 at 11:56
  • _"How do i echo the error"_ - https://stackoverflow.com/a/20203870/1427878 – CBroe May 20 '22 at 12:00
  • 1
    I check the code its working and I receive email. Please check these 1. $from variable contain correct email if you don't create that email in hosting it's creating issue 2. when submit data check post request , All variables are filled or not – RIZI May 20 '22 at 12:25

0 Answers0